Business Component Mode method

Official Content
This documentation is valid for:

Shows the present first level Transaction mode of a variable based on a Business Component.

It only applies for reading purposes, to obtain the present first level mode of a Transaction executed as Business Component.

The default mode when you work with a Business Component variable, is Insert ('INS'). Then, suppose you assign values to the Business Component variable properties. Before applying the Save method the mode is Insert, but after saving, the mode changes to Update ('UPD') and the record keeps instantiated in memory. 

In the case you apply the Load method to a Business Component variable in order to retrieve information from the database, the mode is set to Update and it keeps after invoking the Save method.
 

Syntax

&VbleBasedOnBC.Mode()

Where:

&VbleBasedOnBC
      Is a variable defined in a GeneXus object, based on a Business Component.

The result returned by the method is a string that indicates the mode. The result can be assigned to a character variable or showed using Msg function as the following example shows, etc.


Example

Suppose you define the Customer Transaction as Business Component (by setting its Business Component property = True):

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

Rule:
Default(CustomerAddedDate,&today);

Accordingly, a Business Component data type of the Customer Transaction is automatically created in the Knowledge Base and you can define a variable of the new type created in any object. Thus, you can define a variable named &Customer based on the Customer type in any object.

The following code can be defined in that object, for example, for testing what the method provides. If the object is a Procedure, the code can be included in its source:

   &Customer = new()
   msg(&Customer.Mode())                         //The mode is 'INS'
   &Customer.CustomerName  = 'Susan Brown'
   &Customer.CustomerEmail  = 'SBrown@mail.com'
   &Customer.Save()
   msg(&Customer.Mode())                         //The mode is 'UPD'
   commit


See also

Business Components Methods