Search code examples
c#.netdynamics-crmdynamics-365

Retrieve "Applicable When" and "Success Criteria" from Dynamics CRM SLA programmatically


Currently developing a console application to check all the SLAs in the Dynamics 365 instance.

How to retrieve the "applicable when" and "success criteria" from Dynamics CRM SLA programmatically?


Solution

  • That information is stored in the applicablewhenxml and successconditionsxml fields of the slaitem entity. You can use the following FetchXML to retrieve them:

    <fetch>
      <entity name="slaitem" >
        <attribute name="applicablewhenxml" />
        <attribute name="successconditionsxml" />
      </entity>
    </fetch>
    

    As you can imagine from the names, the information is stored as XML. For example, for a success condition of Status equals to Active:

    <and>
       <condition>
          <column id="colEntity" value="incident" />
          <column id="colAttribute" value="statecode" />
          <column id="colOperator" value="eq" />
          <column id="colStaticValue" value="0" dataslugs="" />
       </condition>
    </and>