Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Activity panel stays stuck in loading state after call custom action through Web API

Posted on by 75

Hello everyone!

I'm facing this issue:

I modified the Resolve and Cancel case buttons in the incident ribbon to show custom modal window, where the users have to select a reason and write a description for the action (resolve or cancel) they're doing. I'm using Xrm.Internal.openDialog to open the modal window.

For the cancel action, I've created a custom activity for showing it in the activity panel of the incident form. Also, I've created a custom action to create this activity and change the incident state to cancelled. I call this action, and the 'CloseIncident' action (for resolving the case), within js script as follows:

For cancel:

function cancelIncident(closeParams) {
    var incidentId = Xrm.Page.data.entity.getId();
    incidentId = incidentId.replace(/[{}]/g, "");

    var parameters = {
        subject: closeParams.reasonText,
        description: closeParams.description
    };

    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/incidents(" + incidentId + ")/Microsoft.Dynamics.CRM.uit_cancelIncident", 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) {
                Xrm.Page.ui.refreshRibbon();
                Xrm.Page.data.refresh();
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send(JSON.stringify(parameters));
}

For resolve:

function resolveIncident(closeParams) {
    var incidentId = Xrm.Page.data.entity.getId();
    incidentId = incidentId.replace(/[{}]/g, "");
    var incidentresolution = {
        "subject": closeParams.reasonText,
        "incidentid@odata.bind": "/incidents(" + incidentId + ")",
        "timespent": 0,
        "description": closeParams.description
    };

    var parameters = {
        "IncidentResolution": incidentresolution,
        "Status": 5
    };

    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Page.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) {
                Xrm.Page.ui.refreshRibbon();
                Xrm.Page.data.refresh();
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send(JSON.stringify(parameters));
}

As you can see, I call the actions via WEB API, and refresh the ribbon and data as success actions. Everythings works good, but when I want to see the actitivies created by these to actions (in the Activity tab of the social pane), says 'Loading...' and stays stuck. The following image shows what I've said (it's in spanish):

5037.2.PNG

If I refresh the browser, or click at 'Order by' icon on the activity tab, shows the activities. 

Anyone has experienced this?

The CRM version is Dynamics 365 8.2.2 On Premise.

Thanks in advance!

*This post is locked for comments

  • Hugo G. Morillo Profile Picture
    Hugo G. Morillo 75 on at
    RE: Activity panel stays stuck in loading state after call custom action through Web API

    Any ideas?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans