Returns the last stored value of a given attribute.
Attribute.GetOldValue()
Type Returned:
Same as the Attribute's type
Objects: Transaction
Generators: .NET, Java, RPG, Cobol, Visual FoxPro (up to GeneXus X Evolution 3), Ruby (up to GeneXus X Evolution 3)
Returns the last stored value, although not already committed 1, of a certain attribute.
The type definition that is returned is equal to the Attribute's type definition.
If Attribute is a non-redundant formula, the returned value is the result of evaluating the formula using the last stored values of the attributes involved in the formula.
1 That means, if the GetOldValue is executed with the AfterValidate Triggering event, it will retrieve the new value.
Note: The GetOldValue method used within a rule doesn't return values to the user.
msg('Current name: ' + CustomerName + NewLine() + 'Previous name: ' + GetOldValue(CustomerName)) on AfterUpdate;
Supposing the current CustomerName value is 'John Doe' and the previous CustomerName value was 'Peter Parker' it will message:
'Current name: John Doe'
'Previous name: '
So, use the GetOldValue method as follows:
&CustomerName = GetOldValue(CustomerName) on AfterUpdate;
msg('Current name: ' + CustomerName + NewLine() + 'Previous name: ' + &CustomerName) on AfterUpdate;