Notifications
Announcements
No record found.
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
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();
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.
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!.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2