I want to be able to prevent delete (from Commerce Manager) of an Organization when certain criterias are met, i.e. it has Contacts tied to it.
What is the best approach to do this?
I have looked into doing a Handler/IPlugin that listens to the delete event ( https://world.episerver.com/documentation/developer-guides/commerce/business-foundation/Working-with-entity-objects/). But how do I cancel the delete? Thowing an exception seems to cancel it, but is that the way to do it? And how do I display a custom error message to the user? I don't want to show the generic "Not all selected items were processed. It may depend on system restrictions or security settings."
There is unfortunately no way to display a nice message as you want, as I know of. Organization is a BF object and the abstraction is very "deep", so it'd be very difficult to change the default behavior