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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to check case status

(0) ShareShare
ReportReport
Posted on by 790

dear all

 

I have a customized business process flow on OPPORTUNITY , at a particular stage, a CASE will be automatically created based on some logic , now, i need to check the status of this originated case before i allow the user to proceed further on the opportunity .

 

Please check the following image.

Please help me ASAP as this is very crucial to my customer.

 7888.image.png

Thanks,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Ahmed ,

    You can call web API request using JS function to get the status  like below.

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/incidents?$select=statecode,statuscode&$filter=incidentid eq B9F65A9B-8049-E811-A94E-000D3A37870E", 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.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var results = JSON.parse(this.response);
                for (var i = 0; i < results.value.length; i++) {
                    var statecode = results.value[i]["statecode"];
                    var statecode_formatted = results.value[i]["statecode@OData.Community.Display.V1.FormattedValue"];  // retrieve the status example- In Progress

    var statuscode = results.value[i]["statuscode"]; } } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send();


    Hope this helps,

  • Ahmad Saud Profile Picture
    790 on at

    thanks a lot for your prompt response, do you mean that i have to create a webresource (type=JavaScript), if yes, then how to call it?

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Ahmed ,

    Yes you need to create JavaScript web resource -

    // Register the function  OnlloadForm  in form onload 
    function OnlloadForm()
    {
        Xrm.Page.data.process.addOnStageChange(OnStageChange);
    }
    
    function OnStageChange()
    {
    
        var stageName = Xrm.Page.data.process.getSelectedStage().getName().toString();
        var stageID = Xrm.Page.data.process.getSelectedStage().getId().toString();
        if(stageName =="Content Received")
        {
            //Check the status 
    
            var req = new XMLHttpRequest();
            req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/incidents?$select=statecode,statuscode&$filter=incidentid eq B9F65A9B-8049-E811-A94E-000D3A37870E", 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.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
            req.onreadystatechange = function() {
                if (this.readyState === 4) {
                    req.onreadystatechange = null;
                    if (this.status === 200) {
                        var results = JSON.parse(this.response);
                        for (var i = 0; i < results.value.length; i++) {
                            var statecode = results.value[i]["statecode"];
                            var statecode_formatted = results.value[i]["statecode@OData.Community.Display.V1.FormattedValue"];  // retrieve the status example- In Progress
                            // Do your operation here by checking status
                            var statuscode = results.value[i]["statuscode"];
                        }
                    } else {
                        Xrm.Utility.alertDialog(this.statusText);
                    }
                }
            };
            req.send();
        }
    }


  • Ahmad Saud Profile Picture
    790 on at

    thanks alot , i will check and update you soon.

  • Verified answer
    Ahmad Saud Profile Picture
    790 on at

    thanks anyway, but it seems i dont have the required experience to implement and test such advanced customization.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Ahmed ,

    If you are not confident on doing script you may try with workflow although its depends on your requirement . Have a look below article  -

    blogs.msdn.microsoft.com/.../automate-business-process-flow-stages-using-workflows

  • Ahmad Saud Profile Picture
    790 on at

    thanks a lot

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans