Business Component GetOldValues method

Official Content

This method can be applied to a property of a variable based on a business component type of a transaction, in order to retrieve it's value from the database, despite having modified it (having assigned to it another value) in memory.

The objetive of applying this method to a property of a business component variable, is to obtain the previous value that the property still has stored.


Syntax

&VbleBasedOnBCType.PropertyName.Getoldvalue()

Where:

&VbleBasedOnBCType
      Is a variable defined in a GeneXus object, based on a business component type of a transaction.

The result returned by the method is a value that can be assigned to a variable or showed using Msg, etc.

 

Example

Let's suppose we define the Customer transaction as Business Component (by setting its Business Component property = True):

Customer
{
  CustomerId*     (Autonumber property = True)
  CustomerName
  CustomerAddress
  CustomerPhone
  CustomerEmail
  CustomerAddedDate
  CustomerTotalMiles
}

Rules:
Default(CustomerAddedDate,&today);
Error('The customer can't be deleted because he has miles to use') if delete and CustomerTotalMiles>0;

Accordingly, a business component data type of the Customer transaction is automatically created in the KB and we are able to define in any object, a variable of the new type created. Thus, in any object we define a variable named &customer based on the Customer type, and the following code can be defined in that object for example (if the object is a procedure, the code can be included in its source):

&Customer.Load(1)                  
&Customer.CustomerTotalMiles += 500
msg('The customer has' + str(&Customer.CustomerTotalMiles.Getoldvalue()) + ' miles and now is going to have ' + str(&Customer.CustomerTotalMiles))
&Customer.Save()
commit


See also

Business Components Methods

 




Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.