Business Component Mode method

Official Content

This method can be applied to a variable based on a business component type of a transaction, in order to know the present first level transaction mode.

It only applies for read purposes (to obtain the present first level mode of a transaction executed as business component).

The default mode when we work with a business component variable, is Insert ('INS'). Then, let's suppose we 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 we 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

VbleBasedOnBCType.Mode()

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 string that indicates the mode. The result can be assigned to a character variable or showed using Msg as the following example shows, 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
}

Rule:
Default(CustomerAddedDate,&today);

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, 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




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