How to Exit Plugin Successfully RRS feed

  • Question

  • Hello,

    I have a plugin that triggers upon account creation. However I want to check so that if the Account Type is not equal to 'Preferred Customer', then exit the plugin successfully. Is there a way to force the plugin to exit successfully, without outputting error message or anything disruptive?

    Thanks. -tri

    var type = targetEntity.Attributes["accountcategorycode"].ToString();
    if (type == null) && (type != 'Preferred Customer') 
    throw new InvalidPluginExecutionException(4, "Successful"); //question is what should be thrown here? We don't want an error message pop up
    //plugin logic here

    Friday, February 6, 2015 7:43 PM

All replies

  • Hi,
    you can consider a plugin like something that you can put in the middle of the operation.
    So if your plugin doesn't generate any exceptions the user will not be notified.

    Keep in mind that only synchronous plugins display the error message to the user when you launch an InvalidPluginExecutionException (if asynchronous the error will be logged inside CRM)

    in your code just do nothing on your true branch and keep your code inside the else branch

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Friday, February 6, 2015 7:48 PM