Evaluates whether the execution of the Save, Check, Load or Delete methods failed or not. It returns True if the operation failed. Otherwise, it returns False.
&VarBasedOnBC.Fail()
Where:
&VarBasedOnBC
Is a -temporary and local- variable defined in a GeneXus object, based on a Business Component.
Suppose you 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
}
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 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 delete a customer who has some miles to use:
&Customer.Load(15)
&Customer.Delete()
if &Customer.fail()
&Messages = &customer.GetMessages()
for &oneMessage in &Messages
msg(&oneMessage.Description)
endfor
else
commit
endif
Variables defined in this object:
- &messagges: Messages data type (collection)
- &onemessage: Messages.message data type (1 element of the messages collection)
When the fail method is evaluated, it returns True because the error rule was triggered and the deletion couldn't be performed, so the code included in the if body, will be executed.
Available in
Android since GeneXus 17 upgrade 4.
See Also
Error handling in Business Components
Business Components Methods