web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get SLA status in JavaScript

(0) ShareShare
ReportReport
Posted on by

Hello, 

I want to know if there is some way to get the SLA status from JavaScript. 

Thanks to all.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    You can retrieve using web API request, download the CRMRestBuilder and prepare the query.

    Here is sample retrieve multiple all SLA status -

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/slas?$select=description,name,statecode,statuscode", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var results = JSON.parse(this.response);
                for (var i = 0; i < results.value.length; i++) {
                    var description = results.value[i]["description"];
                    var name = results.value[i]["name"];
                    var statecode = results.value[i]["statecode"];
                    var statecode_formatted = results.value[i]["statecode@OData.Community.Display.V1.FormattedValue"];
                    var statuscode = results.value[i]["statuscode"];
                }
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send();


    Sample query fro particular SLA status using SLA id -

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/slas(e5826f37-eb11-4912-a660-50bef2482861)?$select=description,name,statecode,statuscode", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var result = JSON.parse(this.response);
                var description = result["description"];
                var name = result["name"];
                var statecode = result["statecode"];
                var statecode_formatted = result["statecode@OData.Community.Display.V1.FormattedValue"];
                var statuscode = result["statuscode"];
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send();


  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You need to write the web api request to retrieve SLA details. You can use use CRM Rest Builder to build the WEB API request. This is the easiest way to build the query as well as execute it and see the results.

    carldesouza.com/dynamics-crm-rest-builder

    You can download the tool here- github.com/.../releases

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks Ravi, but finally i had to modify the SLA workflow to update a field into incident, and with this do the actions that i need.

    I don´t know that tool, that you suggest, but i think it will be util in the future!.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Ohh, Its a great tool and trust me, if you have want to write a web api request using javascript, there would not be an easy way other than this tool :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans