Executes the equivalent to the delete button in a Transaction Form.
&VarBasedOnBC.Delete()
Where:
&VarBasedOnBC
Is a variable defined in a GeneXus object, based on a Business Component.
When this method is executed, the data previously loaded into memory by using the Load method (*) is deleted, but only if the referential integrity doesn't fail and if error rules don't occur.
(*) This is indispensable, as the data to be deleted must be previously instantiated.
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
}
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 Knowledge Base and you can define a variable of the new type created in any object. Thus, in any object, you can define a variable named &Customer based on the Customer type.
The following code (defined for example in a Procedure Source or inside an Event in a Web Panel object) tries to delete the customer whose Primary Key CustomerId=25:
&Customer.Load(25)
&Customer.Delete()
if &Customer.success()
commit
else
rollback
endif
Availability
This method is available since GeneXus 9.0
See Also
Error handling in Business Components