Evaluates whether the execution of the Save, Check, Load or Delete methods,succeeded or not. It returns True if the operation was successful. Otherwise, it returns False.
&VarBasedOnBC.Success()
Where:
&VarBasedOnBC
Is a variable defined in a GeneXus object, based on a Business Component.
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
CustomerBirthDate
CustomerAddedDate
}
Rules:
Default(CustomerAddedDate,&today);
error('The customer must be 18 years old or more') if CustomerBirthDate.Age()<18;
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.
You can define a variable named &Customer based on the Customer type in any object.
The following code (defined for example in a Procedure Source or inside an Event in a Web Panel object) tries to insert a customer younger than 18 years old:
&Customer.CustomerName='Tina Parker'
&Customer.CustomerAddress='18001 Collins Avenue'
&Customer.CustomerPhone= '877-219-8890'
&Customer.CustomerEmail= 'tinaparker@mail.com'
&Customer.CustomerBirthDate= ymdtod(2010,10,08)
&Customer.save()
If &Customer.success()
commit
else
&Messages = &customer.GetMessages()
for &oneMessage in &Messages
msg(&oneMessage.Description)
endfor
endif
Variables defined in this object:
- &messagges: Messages data type (collection)
- &onemessage: Messages.message data type (1 element of the messages collection)
When the Success method is evaluated, it returns False because the error rule was triggered and the save wasn't successful, so the code included in the else, will be executed.
Available in
Android since GeneXus 17 upgrade 4.
Error handling in Business Components
Business Components Methods