Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get SLA status in JavaScript

Posted on by Microsoft Employee

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

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: GET SLA STATUS

    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 :)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: GET SLA STATUS

    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!.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: GET SLA STATUS

    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.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: GET SLA STATUS

    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();


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans