Determining if a record is new during BeforeSave event


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, Peter has the right idea.  The best way to determine a state of a row is by using the RowState. 
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ah...great idea. I'll try that.



Thanks Peter
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Greg,

I think:

If BO.CurrentRow.RowState = DataRowState.Added Then

......

End If

Will do the job

Cheers, Peter


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm about to subclass the BusinessLayer type to handle some auditing. I'll need to know if a record is a new record. I was going to override the Save method (or maybe the OnBeforeSave method). In this I'll need to figure out if the record is new. If it isn't new, I'll need to save away the old values to my audit history table, but I won't need to call this for new records.



My first thought was to check the PK field (which in my case will always be an integer/identity field), to see if its value was < 0. Is there a better way?



Thanks!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search