locked
Querying for SdkMessageProcessingSteps for a specific entity RRS feed

  • Question

  • Is there a way to query for all the SdkMessageProcessing steps (aka plugin steps) registered for a specific entity across all the plugin
    assemblies that have steps registered for that entity.

    I'm looking to programatically disable all the plugin steps registered for a specific entity prior to running unit tests and
    enable them after the unit tests have completed.


    -Abhijeet

    Friday, August 9, 2013 6:42 AM

All replies

  • HI Abhijeet,

           You could use a Fetch XML like the following, replace the 1 in the last filter to the entity type code you want to filter, on this example is filtering by typecode 1 which is the Account entity.


    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> <entity name="sdkmessageprocessingstep"> <attribute name="name" /> <attribute name="description" /> <attribute name="eventhandler" /> <attribute name="impersonatinguserid" /> <attribute name="supporteddeployment" /> <attribute name="statuscode" /> <attribute name="statecode" /> <attribute name="sdkmessagefilterid" /> <attribute name="sdkmessageid" /> <attribute name="filteringattributes" /> <attribute name="configuration" /> <attribute name="asyncautodelete" /> <attribute name="plugintypeid" /> <filter type="and"> <condition attribute="plugintypeidname" operator="not-like" value="%internaloperation%" /> </filter> <link-entity name="sdkmessagefilter" from="sdkmessagefilterid" to="sdkmessagefilterid" visible="false" alias="a1"> <attribute name="secondaryobjecttypecode" /> <attribute name="primaryobjecttypecode" /> <filter type="and"> <condition attribute="primaryobjecttypecode" operator="eq" value="1" /> </filter> </link-entity> </entity> </fetch>



    Regards,
    Damian Sinay

    Friday, August 9, 2013 7:40 AM
  • Hi Abhijeet,

    Check out this blog http://www.magnetismsolutions.com/blog/roshanmehta/2013/06/17/crm-2011-automatically-enable-disable-plug-ins-and-workflows

    You might be able to identify the entity that the plugin is registered on based on the name of the plugin step.

    I hope this helps.

    Friday, August 9, 2013 8:00 AM
  • Abhijeet,

    Use the following function do disable the specifice entity all sdk steps using the CRM service ,

    Here you need to provide the entity etc value as parameter

     public void DisableSDKsteps(string etcValue)
            {
                string fxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
      <entity name='sdkmessageprocessingstep'>
        <attribute name='name' />
        <link-entity name='sdkmessagefilter' from='sdkmessagefilterid' to='sdkmessagefilterid' visible='false' alias='a1'>
          <attribute name='secondaryobjecttypecode' />
          <attribute name='primaryobjecttypecode' />
          <filter type='and'>
            <condition attribute='primaryobjecttypecode' operator='eq' value='"+etcValue+"' />
          </filter>
        </link-entity>
      </entity>
    </fetch>";
                EntityCollection results = _serivce.RetrieveMultiple(new FetchExpression(fxml));
                if (results != null && results.Entities.Count > 0)
                {
                    foreach (Entity ent in results.Entities)
                    {
                        SetStateRequest req = new SetStateRequest()
                        {
                            EntityMoniker = new EntityReference(ent.LogicalName, ent.Id),
                            State = new OptionSetValue(1),
                            Status = new OptionSetValue(2)
                        };
                        _serivce.Execute(req);
                    }
                }
            }

    Hope this will helpfull to you,


    • Proposed as answer by M. SOMASHEKAR Friday, August 9, 2013 10:15 AM
    Friday, August 9, 2013 9:36 AM