/// <summary> /// Called after Import completes. /// </summary> /// <returns></returns> public override bool AfterPrimaryImport() { var version = CrmSvc.ConnectedOrgVersion; //Enable all the steps in the plugin assembly if (CrmSvc != null && CrmSvc.IsReady) { var assemblyname = "CrmAsyncRequestResponseSample.Plugins"; // Create the QueryExpression object to retrieve plug-in type var query = new QueryExpression(); query.EntityName = "plugintype"; query.Criteria.AddCondition("assemblyname", ConditionOperator.Equal, assemblyname); var retrievedPluginType = CrmSvc.RetrieveMultiple(query)[0]; var pluginTypeId = (Guid)retrievedPluginType.Attributes["plugintypeid"]; query = new QueryExpression(); // Set the properties of the QueryExpression object. query.EntityName = "sdkmessageprocessingstep"; query.ColumnSet = new ColumnSet(new[] { "sdkmessageprocessingstepid", "statecode" }); query.Criteria.AddCondition(new ConditionExpression("plugintypeid", ConditionOperator.Equal, pluginTypeId)); var retrievedSteps = CrmSvc.RetrieveMultiple(query); foreach (var step in retrievedSteps.Entities) { // Enable the step by setting it's state code step.Attributes["statecode"] = new OptionSetValue(0); // 0 = Enabled step.Attributes["statuscode"] = new OptionSetValue(1); // 1 = Enabled CrmSvc.Update(step); } return(true); // Do nothing here/ } return(false); }
private void EnablePluginSteps() { LogStart("EnablePluginSteps"); var assemblyname = "FedBizApps.RequestManagement.Plugins"; // Create the QueryExpression object to retrieve plug-in type var query = new QueryExpression { EntityName = "plugintype" }; query.Criteria.AddCondition("assemblyname", ConditionOperator.Equal, assemblyname); var retrievedPluginType = CrmSvc.RetrieveMultiple(query)[0]; var pluginTypeId = (Guid)retrievedPluginType.Attributes["plugintypeid"]; query = new QueryExpression { EntityName = "sdkmessageprocessingstep", ColumnSet = new ColumnSet(new[] { "sdkmessageprocessingstepid", "statecode" }) }; // Set the properties of the QueryExpression object. query.Criteria.AddCondition(new ConditionExpression("plugintypeid", ConditionOperator.Equal, pluginTypeId)); var retrievedSteps = CrmSvc.RetrieveMultiple(query); foreach (var step in retrievedSteps.Entities) { // Enable the step by setting it's state code step.Attributes["statecode"] = new OptionSetValue(0); // 0 = Enabled step.Attributes["statuscode"] = new OptionSetValue(1); // 1 = Enabled CrmSvc.Update(step); } LogEnd("EnablePluginSteps"); }