The delete method executes something equivalent to what happens when the user presses the delete button in a Transaction Form.
When the method is executed (because it's applied to a variable based on a business component type of a Transaction), the data previously loaded into memory by using the Load method (*), is deleted only if the referential integrity doesn't fail (because it is checked) and if error rules don't occur (because the rules defined in the Transaction are triggered).
(*) This is indispensable because the data to be deleted must be previously instantiated.
Is a -temporary and local- variable defined in a GeneXus object, based on a business component type of a Transaction.
Suppose you define the following Transaction as Business Component (by setting its Business Component property = True):
CustomerId* (Autonumber property = True)
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 you are able to define in any object, a variable of the new type created. Thus, in any object, you 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) tries to delete the customer whose primary key CustomerId=25:
This method is available since GeneXus 9.0.
Error handling in Business Components