locked
How to trigger SalesOrder Cancel through a plugin RRS feed

  • Question

  • I have a custom plugin which is registered on After Operation Update on SetState and SetStateDynamicEntity but for some reason the plugin is not getting fired not sure what am I missing.

    Here is the code that I have so far.

    if(this.PluginExecutionContext.InputParameters.Contains("EntityMoniker"))

    {

    // Work with the Moniker

    vartargetEntity = (EntityReference)this.PluginExecutionContext.InputParameters["EntityMoniker"];

    thrownewInvalidPluginExecutionException(this.PluginExecutionContext.MessageName);

    }

    Tuesday, December 15, 2015 3:59 PM

Answers

  • this is how I now trigger for a cancel Invoice on a PostUpdate stage

    if(this.PluginExecutionContext.ParentContext.MessageName == "SetStateDynamicEntity")
                {
                    OptionSetValue cancelInvoice = (OptionSetValue)this.PluginExecutionContext.ParentContext.InputParameters["State"];
                   if(cancelInvoice.Value == 3)
                   {
                       // Add logic for cancel for invoice 
    
                   }
    
    
    
    
    
    
    

    }

    And here is for Sales Order

    if(this.PluginExecutionContext.ParentContext.MessageName == "Cancel")
                     {
                        //Add logic for cancel. 
                     }

    • Marked as answer by SPCRM2011 Tuesday, December 15, 2015 5:53 PM
    Tuesday, December 15, 2015 5:51 PM