Following JavaScript code can be used to Resolve Incident using JavaScript and WebApi:
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));
Hi, I just want to know is there any workaround to run the crm custom report using web api c#??
Hello Sujit, Can you please elaborate what’s your goal for the report?
HI Andrii,
How do I update this to close the incident with a specific resolution reason. Works fine with -1 to use the default resolution reason but we have over 10 values that could be selected. The user is setting the reason as a field on the case form, which has been done to allow different filtered lists of resolution reasons per case type.
Thanks, Chris
Hello Chris,
To define the reason you will have to pass proper value to “Status” field of the custom workflow action. It accepts whole numbers and if on UI side you have optionset for that I would recommend to create a hidden whole number field and on change of this optionset copy the value to that hidden whole number field and use it in workflow.
Thanks,
Andrew