web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

status reason displays blank

(0) ShareShare
ReportReport
Posted on by 40

when closing a case through JS, the status reason shows blank, it should be display "closed", I believe the status shows "resolved"

0027.Untitled.png

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Please share your JS code to us so that we could help you find out the reason.

    For example, you should set the "statusReason" to 1 if you want to close the case as resolved.

    pastedimage1579743903738v1.png

    Sample code for you.

    function closeCase(){
      var status=Xrm.page.getAttribute("statuscode");
      var statecode=Xrm.page.getAttribute("statecode");
      if(status!=null&&status!=undefind&&statecode!=null&&statecode!=undefind){
         status.setValue(1);
         statecode.setValue(5);
      }
    }

    Best Regards,

    Leo

  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at

    Hello,

    You can try the below

    1. Check If this is the OOB Status Reason field and not another custom field with the same label

    2. Check if there is an empty value that has been added to the Status Reson field and verify the status reason transition settings

    2. Run an Advanced Find query on the case entity and add the Status Reason field to check its value

    3. Check if there are any other process (plugin, WF...) that is setting the status reason field to empty

  • sdnd2019 Profile Picture
    40 on at

    I am in the process of upgrading from V8.2 to V9.0, the JS code is fine in V8.2

    function closeCase(){
        debugger;
          var caseId = Xrm.Page.data.entity.getId();
          var context;
          caseId = caseId.replace("{", "").replace("}", "");
          var incidentresolution = {
            "subject": "My Subject",
            "incidentid@odata.bind": "/incidents("   caseId   ")",//Id of incident
            "timespent": 60,
            "description": "My Description"
        };
        
        var parameters = {
        "IncidentResolution": incidentresolution,
        "Status": -1
        };
        
        if (typeof GetGlobalContext === "function") {
        context = GetGlobalContext();
         } else {
        context = Xrm.Page.context;
        }
        
            Xrm.Page.data.save().then(
            function(){
                alert("Form Save Successfully");
                    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("Case Closed");
                                    Xrm.Page.data.refresh(false);
                                   } 
                              else {
                                    var errorText = this.responseText;
                                    alert("Case not Closed"   errorText);}
                                }
                   };
                    req.send(JSON.stringify(parameters));
         },
            function(errorCode,message){
                alert("Save Failed "  message);
            });
    }

  • Mayank Pujara Profile Picture
    830 on at

    I guess it is worth checking if  whether  default status reason is set for Close State of Case Entity or not in customization area for this.

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans