Business Component GetMessages method

Official Content
This documentation is valid for:

This method can be applied to a variable based on a business component type of a transaction, after executing the Save, Check, Load or Delete methods, in order to get the collection of errors that occured (those automatically checked by GeneXus as well as the Msg and Error rules defined in the transaction).

Syntax

&messages=&VbleBasedOnBCType.GetMessages()

Where:

&messages
     Is a -temporary and local- variable defined in a GeneXus object, based on the structured data type named Messages which is automatically defined by GeneXus in every KB:

     MessagesSDTImage

  

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

Example

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

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

Customer 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 a certain object we define a variable named &customer based on the Customer type.

In the same object, we define also the following two variables:

&Messages: of the Messages data type, collection
&oneMessage: of the Messages.Message data type, which is 1 element in the collection

Then we define the following code in the object (for example if the object is a procedure, we define this code in its source):

&Customer.Load(18)
&Customer.Delete()
if &Customer.success()
   commit
else
   &Messages = &customer.GetMessages()
   for &oneMessage in &Messages
       msg(&oneMessage.Description)
   endfor   
endif

 

See also

Error handling in Business Components
Business Components Methods





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