Original Field Value


Author
Message
Tim Dol
Tim Dol
StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
I need to compare the current value of a field with the original value. Where can I find the original value within the BO. 

Thanks

Tim

Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
To find the original values versus the new values (current values) use something like this:



'-- Get the current value of the current row

' Note the use of the FieldNames enum (created for each BO)

Dim currValue As String = MyBo.CurrentRow.Item(MyBoFieldNames.MyField,DataRowVersion.Current)

'-- Get the original value of the current row

Dim orgValue As String = MyBo.CurrentRow.Item(MyBoFieldNames.MyField,DataRowVersion.Original)



'-- To loop through all the rows, checking if the row is dirty, then getting the original values.

For Each row As DataRow In MyBo.CurrentDataTable.Rows

'-- Get org Value if its dirty

If row.RowState <> DataRowState.Unchanged Then

'-- Get original values

' Note that the field name is just referenced by its name as a string here.

Dim orgValue2 As Integer = row.Item("intField",DataRowVersion.Original)

End If

Next





You will need to do this BEFORE the record is saved. When it is saved, the original values are reset to the current values. I'd also make sure to check AFTER the rules are checked, in case there are broken rules. Likely, I'd do the checking after the rules are checked, save away the results, then take action after the save actually works. I might also do it within a transaction, just in case...



Good luck!
Tim Dol
Tim Dol
StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)StrataFrame User (368 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
Thanks a lot Greg, this will definetly get me started in the right direction. Much appreciated.Smile

Tim

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm glad I've been a help! Good luck!
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Greg is perfectly correct in the use of the DataRowVersion.Original when you call the CurrentRow("FieldName", version) property, but in the AfterSave event, the changes have already been comitted to the DataTable.

Even if you change the AcceptRowChangeMode to AfterTableSave, the whole table will have been accepted before the AfterSave event has been copied.  The only way that I can think to test this would be to copy the CurrentDataTable before the save.  If you use CurrentDataTable.Copy() and store the result in a variable, it will take an exact snapshot of the data in the DataTable and you'll be able to use that to get your original values.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Tim Dol - 17 Years Ago
Greg McGuffey - 17 Years Ago
Tim Dol - 17 Years Ago
Greg McGuffey - 17 Years Ago
Tim Dol - 17 Years Ago
                         To find the original values versus the new values (current values) use...
Greg McGuffey - 17 Years Ago
                             Thanks a lot Greg, this will definetly get me started in the right...
Tim Dol - 17 Years Ago
                                 I'm glad I've been a help! Good luck!
Greg McGuffey - 17 Years Ago
                                     Greg is perfectly correct in the use of the DataRowVersion.Original...
StrataFrame Team - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search