i am working on Microsoft Dynamics 365 on-premises and i want to develop a custom tool using C# that can disable the plugin steps, i tried the below code but it did not work with me, the code executed to the end but nothing happen .
any recommendations please ?
public string EnablePlugin(IOrganizationService orgService, bool enable, string pluginName)
{
var qe = new QueryExpression("sdkmessageprocessingstep");
qe.ColumnSet.AddColumns("sdkmessageprocessingstepid", "name");
qe.Criteria = new FilterExpression();
qe.Criteria.AddCondition("name", ConditionOperator.Equal, pluginName);
var step = orgService.RetrieveMultiple(qe).Entities.First();
var pluginId = (Guid)step.Attributes["sdkmessageprocessingstepid"];
MessageBox.Show(pluginId.ToString());
int pluginStateCode = enable ? 0 : 1;
int pluginStatusCode = enable ? 1 : 2;
OrganizationResponse res = orgService.Execute(new SetStateRequest
{
EntityMoniker = new EntityReference("sdkmessageprocessingstep", pluginId),
State = new OptionSetValue(pluginStateCode),
Status = new OptionSetValue(pluginStatusCode)
});
return "Ok";
}

Report
All responses (
Answers (