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.
Let's suppose we 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 we are able to define in any object, a variable of the new type created. Thus, in any object, we 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