﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Original Field Value</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 30 May 2026 07:18:17 GMT</lastBuildDate><ttl>20</ttl><item><title>Original Field Value</title><link>http://forum.strataframe.net/FindPost11093.aspx</link><description>I need to compare the current value of a field with the original value. Where can I find the original value within the BO.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Tim</description><pubDate>Tue, 28 Aug 2007 08:57:05 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11145.aspx</link><description>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. &lt;/P&gt;&lt;P&gt;Even if you change the AcceptRowChangeMode to AfterTableSave, the whole table will have been accepted before the AfterSave event has been copied.&amp;nbsp; The only way that I can think to test this would be to copy the CurrentDataTable before the save.&amp;nbsp; 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.</description><pubDate>Tue, 28 Aug 2007 08:57:05 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11135.aspx</link><description>I'm glad I've been a help!  Good luck!</description><pubDate>Mon, 27 Aug 2007 23:21:19 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11133.aspx</link><description>Thanks a lot Greg, this will definetly get me started in the right direction. Much appreciated.:)&lt;/P&gt;&lt;P&gt;Tim</description><pubDate>Mon, 27 Aug 2007 17:48:58 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11127.aspx</link><description>To find the original values versus the new values (current values) use something like this:&lt;br&gt;
&lt;br&gt;
[codesnippet]'-- Get the current value of the current row&lt;br&gt;
'    Note the use of the FieldNames enum (created for each BO)&lt;br&gt;
Dim currValue As String = MyBo.CurrentRow.Item(MyBoFieldNames.MyField,DataRowVersion.Current)&lt;br&gt;
'-- Get the original value of the current row&lt;br&gt;
Dim orgValue As String = MyBo.CurrentRow.Item(MyBoFieldNames.MyField,DataRowVersion.Original)&lt;br&gt;
&lt;br&gt;
'-- To loop through all the rows, checking if the row is dirty, then getting the original values.&lt;br&gt;
For Each row As DataRow In MyBo.CurrentDataTable.Rows&lt;br&gt;
  '-- Get org Value if its dirty&lt;br&gt;
  If row.RowState &lt;&gt; DataRowState.Unchanged Then&lt;br&gt;
    '-- Get original values&lt;br&gt;
    '    Note that the field name is just referenced by its name as a string here.&lt;br&gt;
    Dim orgValue2 As Integer = row.Item("intField",DataRowVersion.Original)&lt;br&gt;
  End If&lt;br&gt;
Next&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
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...&lt;br&gt;
&lt;br&gt;
Good luck!</description><pubDate>Mon, 27 Aug 2007 16:59:53 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11125.aspx</link><description>Actually I have been looking at this on a row by row basis, when I really should be looking at this from the currentdatatable perspective, so I guess I will need to loop through the BO and check values for any rows that have changed. &lt;/P&gt;&lt;P&gt;Any suggestions on how/where I should be adding the compare logic,&amp;nbsp;(BeforeSave, AfterSave?)&amp;nbsp;&amp;nbsp;to implement this type of logic and how I get access to original values.&lt;/P&gt;&lt;P&gt;Basically I need to execute routines&amp;nbsp;when specific fields have been changed. Example: Automatically create a note on the customer's account when the user changes the credit limit.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Tim</description><pubDate>Mon, 27 Aug 2007 16:18:15 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11120.aspx</link><description>Oh, I believe the original value is "gone" in the AfterSave event. I.e. once the BO saves the data, the datatable updates its original value to the latest value so it knows when it is dirty again.  You might need to figure this out in the BeforeSave event.  At least you could see if you can get access to the original value in the BeforeSave event.</description><pubDate>Mon, 27 Aug 2007 14:20:22 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11118.aspx</link><description>I checked the current row and the value seems to reflect the changes I made to the field. &lt;/P&gt;&lt;P&gt;I want to be able to compare the current value to the original value in the AfterSave event, if the original data is available. I need to perform some automated functions if certain values change so I need access to the original data.&amp;nbsp;I'm sure Trent told me a while back where to find this information but I can't find the post.&lt;/P&gt;&lt;P&gt;Tim</description><pubDate>Mon, 27 Aug 2007 13:11:05 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: Original Field Value</title><link>http://forum.strataframe.net/FindPost11106.aspx</link><description>If the field is a normal field, then I believe the underlying DataTable tracks this. Check out the properties for the CurrentRow (which just wraps the current DataRow of the underlying DataTable).  &lt;br&gt;
&lt;br&gt;
If it's a custom field, then you'd have to manage the original value yourself.</description><pubDate>Mon, 27 Aug 2007 10:46:07 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>