Dynamics 365 WEB API · Dynamics CRM Javascript · Javascript

{Dynamics CRM Web Api} Resolve Case

In today’s blog I will explain how to close incident from web api. When we Resolve case from Case form system creates record in Incident resolution entity. And the changes the status of the case.

Same way we have to first create record in Incident Resolution entity from web api and then use CloseIncident action to change the status of the case.

Step 1:

Use below code to create Incident Resolution entity record using web api. We can map multiple fields while creating the record those are visible on Case Resolve dialog.

var entity = {};
entity.subject = "Problem Solved";
entity.description="Issue fixed";//Remarks
entity["incidentid@odata.bind"] = "/incidents(ca9e62a8-90df-e311-9565-a45d36fc5fe8)";
entity.timespent = 5;//Total Time
entity.totaltimespent = 15;//Billable time
entity.resolutiontypecode = 5;//Problem Solved

Xrm.WebApi.online.createRecord("incidentresolution", entity).then(
    function success(result) {
        var newEntityId = result.id;
    function(error) {

Step 2:

Now we have to execute IncidentResolution action from Web api. Use below code to invoke action.

var parameters = {};
var incidentresolution = {};
incidentresolution.activityid = "00000000-0000-0000-0000-000000000000"; //Pass entity ID from previous web api response 
incidentresolution["@odata.type"] = "Microsoft.Dynamics.CRM.incidentresolution";
parameters.IncidentResolution = incidentresolution;
parameters.Status = 5;//Problem Solved

var closeIncidentRequest = {
    IncidentResolution: parameters.IncidentResolution,
    Status: parameters.Status,

    getMetadata: function() {
        return {
            boundParameter: null,
            parameterTypes: {
                "IncidentResolution": {
                    "typeName": "mscrm.incidentresolution",
                    "structuralProperty": 5
                "Status": {
                    "typeName": "Edm.Int32",
                    "structuralProperty": 1
            operationType: 0,
            operationName: "CloseIncident"

    function success(result) {
        if (result.ok) {
            //Success - No Return Data - Do Something
    function(error) {

Hope this helps!


5 thoughts on “{Dynamics CRM Web Api} Resolve Case

  1. Hi there

    Thanks for sharing this post, it helps. However, there’s a little tweak that I had to get done in order to get it working in my case, instead of defining activityid in incidentresolution object, I defined the incidentid by using odata binding:

    incidentresolution.activityid = “00000000-0000-0000-0000-000000000000”;

    incidentresolution[“incidentid@odata.bind”] = “/incidents(” + id + “)”;

    Thanks, though. Cheers



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s