November Happy Hour will be moved to Thursday December 5th.

Prevent delete of Organization in certain cases?

Vote:
 

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." 

#206830
Aug 30, 2019 16:10
Vote:
 

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 

#206854
Sep 02, 2019 11:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.