locked
Supress Delete action in plug-in RRS feed

  • Question

  • The CRM implementation that I'm working on has relationship (1:N) between Contact and a Custom Entity 'Case'. Some of the users has Delete permissions on Contact entity. Before deleting the Contact I need to check if it has any associated cases. If it does, then system should not allow user to delete the Contact.

    To fulfill this requirement I've created a plug-in and registered it on "Delete" message of Contact entity. The plug-in is registered as 'Pre' event. Here I can check if Contact has any Cases associated with it. But I'm not able to supress the Delete action. Here I can throw an exception so that Contact will not get deleted. But I do not want to show any error message to user. Is there any way we can suppress Deletion of the Contact if there are any cases associated with it?

    Thursday, July 8, 2010 4:05 PM

Answers

  • You can create such behaviour without plugins - just modify relation between entities your entities - Delete behaviour change to restrict delete.

    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Ahmed ElNoby Tuesday, July 13, 2010 12:14 PM
    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 8, 2010 6:28 PM
    Moderator
  • You can open the message from the Contact entity under Customize Entity and replace the default message that appears when a user takes the delete action with a custom message. 

    Regards, Donna

            Windows Live Blog

    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 22, 2010 3:10 PM
  • It is not possible to supress the error usiing plu-in, you cannot stop the execution of the plug-in. Even When you throw the BLANK MESSAGE using InvalidPluginExecutionException, it will pop-up on user screen.


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 22, 2010 5:03 PM

All replies

  • You can create such behaviour without plugins - just modify relation between entities your entities - Delete behaviour change to restrict delete.

    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Ahmed ElNoby Tuesday, July 13, 2010 12:14 PM
    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 8, 2010 6:28 PM
    Moderator
  • I agree, we can control this behavior thru relationship but I need to show a custom message instead of CRM default message.
    Tuesday, July 13, 2010 8:03 PM
  • You can open the message from the Contact entity under Customize Entity and replace the default message that appears when a user takes the delete action with a custom message. 

    Regards, Donna

            Windows Live Blog

    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 22, 2010 3:10 PM
  • It is not possible to supress the error usiing plu-in, you cannot stop the execution of the plug-in. Even When you throw the BLANK MESSAGE using InvalidPluginExecutionException, it will pop-up on user screen.


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Marked as answer by Jim Glass Jr Thursday, July 22, 2010 7:48 PM
    Thursday, July 22, 2010 5:03 PM