Text Scroll

You must welcome, Thank you for visiting my blog.

Search This Blog

Sunday, June 28, 2020

Case Resolved Using WebAPi in ms crm

var incidentresolution = {
    "subject": "Put Your Resolve Subject Here",
    "incidentid@odata.bind": "/incidents(0A9F62A8-90DF-E311-9565-A45D36FC5FE1)",//Id of incident
    "timespent": 60,//This is billable time in minutes
    "description": "Additional Description Here"
};
 
var parameters = {
    "IncidentResolution": incidentresolution,
    "Status": -1
};
 
var context;
 
if (typeof GetGlobalContext === "function") {
    context = GetGlobalContext();
} else {
    context = Xrm.Page.context;
}
 
var req = new XMLHttpRequest();
req.open("POST", context.getClientUrl() + "/api/data/v8.2/CloseIncident", 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.onreadystatechange = function () {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            //Success - No Return Data - Do Something
        } else {
            var errorText = this.responseText;
            //Error and errorText variable contains an error - do something with it
        }
    }
};
req.send(JSON.stringify(parameters));

No comments:

Post a Comment