Disable All the steps in a Plug

0
77
Forum Post: Change the Filter On option on Opportunity Associated View for Account form


In addition to Alex’s answer, just an brief explanation:

Your code basically seems fine with the exception that you are calling a First method after calling the Retrieve Multiple.

You need to do a For Each statement on the Retrieve Multiple Results of the Entity Collection.

Basically:

EntityCollection steps = orgService.RetrieveMultiple(qe).Entities.Where(x => x.Attributes[“name”].ToString().Contains(pluginName));

foreach (Entity step in steps.Entities)

{

  Guid stepId = step.Id;

  int pluginStateCode = enable ? 0 : 1;

  int pluginStatusCode = enable ? 1 : 2;

  DeactivateStep (stepId, pluginStateCode, pluginStatusCode);

}

// function to Deactivate Each Step

private function DeactivateStep(Guid stepId, int pluginStateCode, int pluginStatusCode)

{

  SetStateRequest request = new SetStateRequest()

  {

     EntityMoniker = new EntityReference(“sdkmessageprocessingstep”, pluginId),

     State = new OptionSetValue(pluginStateCode),

     Status = new OptionSetValue(pluginStatusCode)

  };

  orgService.Execute(request);

}

Hope this helps.



Source link

Leave a reply

Please enter your comment!
Please enter your name here