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):
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