https://www.powerobjects.com/blog/2012/02/02/use-a-dialog-process-in-microsoft-dynamics-crm-to-replace-the-case-resolution-form/
https://crmtipoftheday.com/174/replace-standard-system-dialogs/
function Case_Resolve()
{
//debugger;
try
{
var Case_id = Xrm.Page.data.entity.getId();
Case_id = Case_id.replace("}", "").replace("{", "");
var incidentresolution = {
"subject": "comments", // any comments
"incidentid@odata.bind": "/incidents("+ Case_id +")",//Id of incident
"timespent": 60,//This is billable time in minutes
"description": "RemarkComments" //Remarks
};
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) {
alert("Resolve Successfully");
Xrm.Page.data.refresh();
RefreshPage();
//Success - No Return Data - Do Something
} else {
var errorText = this.responseText;
alert(errorText);
//Error and errorText variable contains an error - do something with it
}
}
};
req.send(JSON.stringify(parameters));
}
catch(Error)
{
alert(Error.message);
}
}
function RefreshPage(){
setTimeout(function () {
Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
}, 2000);
}
No comments:
Post a Comment