Popping up a message box/ alert from Plugin. RRS feed

  • Question

  • Hi Folks,

    I need to display an alert/message box from the plugin. I don't want to use "throw new InvalidPluginExecutionException" as it will roll back the transaction. Please provide your inputs.



    Wednesday, May 7, 2014 11:02 AM

All replies

  • This is not possible from Plugin as it runs directly on server. Plugins are meant to handle only bussines logic (Internal Processing). Hence showing a message box/alert from plugin is not recommended.
    You can achieve your requirement using Javascript only.
    Wednesday, May 7, 2014 11:17 AM
  • The only feedback that a plugin can provide is via the exception, which necessarily rolls back the transaction.

    An alternative approach (if using Crm 2013) would be to create a Action the performs the task you want, and returns a value based on success or failure and call it from javascript

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, May 7, 2014 11:47 AM
  • I remember that I came across the same situation when a customer was very particular that he want an alert on creation. My recollection is hazy but I think we did something like following to achieve it. Its not very clean solution but works when you don't have any other way of doing. 

    • Create a bool type custom field on Entity and add it to hidden section on form. 
    • Register a pre-operation plugin on Create message.
    • Set the custom field value to true
    • On form load, write a JavaScript function to check if custom field value is 'true'.
    • inside the IF condition set the custom field value to 'false'.
    • Throw an alert to display the message you want to display.
    • Proposed as answer by jattscorpion Thursday, May 8, 2014 8:52 AM
    Wednesday, May 7, 2014 2:29 PM