Procedure for Data Verification upon Removal of Entities

Hi,

in my app I need to verify relations between entities before deleting and entity. In the app this is tipically done through a user action by clicking a remove button.

I like the CUBA mechanism for data deletion then it seems pretty straightforward, and if no further verification is needed it works smoothly. However for certain entities I need to doublecheck and give the user customized answers on why an entity of a given type may not be deleted.

What is the recommended way to go? I might need to do this either from a Lookup screen aswell as for a related entity in an Editor screen. I presume I need to override the remove actions in tables, and make the whole verification myself, and in case this verification is affirmative, call dataManager.remove(selectedEntity), or notify the user otherwhise.

This is what I would do at first attempt. Any recommendations are greatly welcome.

Thanks in advance for your support.

Regards,

Carlos.

Hi,

Processing data in the screens in generally not a good idea. If you introduce REST API or ReactJS client for your app, you’ll need to replicate all this logic in REST controller or JS code.

Did you consider Entity Listeners or Entity Changed events? There is a nice guide about decoupling business logic.

Also, you can have a look at Entity’s lifecycle callbacks. You can add them in entity editor screen: image