2578160 - Validation-OnDelete Not Getting Trigerred When Clicking on Tresh button

SAP Knowledge Base Article - Public

2578160 - Validation-OnDelete Not Getting Trigerred When Clicking on Tresh button

Symptom

You extended a SAP Standard Business Object and added a script file Validation-OnDelete to enhance the validation during deletion process and you noticed that the custom validation is not getting trigerred when you click on the Trash button, but if you click on the Tresh button and then click on Save Button, the Validation-OnDelete is trigerred.

Environment

All Versions of SAP Hybris Cloud for Customer and SAP Business ByDesign

Reproducing the Issue

E.g. on Contacts of Customer Accounts (This behavior could be faced on others WoC as well):

1- Open the Cloud Application Studio

2- Login on your system

3- Click on button Start Debbuging and put a breakpoint on the Validation-OnDelete

4- On frontend, Go to the WoC Customer

5- Go to the WoC View Accounts

6- Open a Customer Account

7- Go to Facet Contacts

8- Find the Table CONTACTS and find a Contact for this Customer Account

9- On the right side of the row, find the Column Action where the Trash button (Delete Button of the row) is located

10- Click on the Trash button (Delete the row) and note that the Validation-OnDelete was not trigerred

11- Click on Save Button and note that the Validation-OnDelete was trigerred

Cause

The Validation-OnDelete event runs in the Buffer, it's not trigerred until a Save action get trigerred. When you click on the Trash button, you added a Validation-OnDelete action to the backend buffer and the actions on this buffer will be executed after you trigerred the Save Actions. So to trigger a Validation-OnDelete Event, a Save action should be performed after the Delete Actions get added to buffer.

Usually, when you see a Delete button on the OWL, the Save actions is performed right after the Delete action, so it runs at the same time.

Resolution

1- Debug your logic and check if the Validation-OnDelete is getting trigerred after you perform the Save Action

2- Adapt your logic and development structure to work according to system behavior

See Also

You can check the blog treat "https://archive.sap.com/discussions/thread/3938158" where customer faced a similar issue. Just check the question of “Andres Gutierrez” and the reply from “Victor Silva”.

Keywords

Save; Save Action; Delete; Delete Action; Validation; OnDelete; Validation-OnDelete; Trigger; Trigerred; , KBA , AP-RC-BDS-BO , ByDesign Studio BO definition/generation , Problem

Product

SAP Business ByDesign all versions ; SAP Hybris Cloud for Customer all versions