Event Handlers - Run Code Before/After Deleting an Item

Hello guys,

Is there any way to run code before or after deleting an entry? We have event handlers to handle the onBeforeSave() and the onAfterSave() , but is there any way to do this when deleting an entry? Or a way to create an event listener from scratch?

Speaking on event handlers, there should be a handler for on product change event, many apps depends on the product ID, when opening other products (e.g. from search bar or related products), only the product itself change, but its reviews still the same.

Ahmad, if the code that you want to run is not page-related but rather data-related, you could use the Before Remove or After Remove hook.

Thank you @tony-brunsman for your reply.
So basically, if I want to run non-data related code, the only way is to disconnect the connection between the delete button and the dataset, adds an onClick() event handler to run the needed code, then remove the item by $w(‘dataset’).remove() ?

@ahmadnasriya You pretty much answered your own question. I suspect that you will be quite busy fine-tuning how this is implemented in the dynamics of the page that it’s on.

@tony-brunsman I just wanted to know if there are other ways to achieve the same goal, that’s it.

Anyway, thanks a lot for your answer :wink: