Hi, I have a Custom "Cancel Case"button which executes a Dialog in order to get a detailed reason for Cancelling the case from the Agent performing that action (our customers wants to get such a detailed information and not relying in the built-in Cancel reasons in the CRM). After getting the text of reason, the Dialog sets the state of the Case record on Cancelled. The code, which I borrowed from the Internet, is as follows:
runDialogAndRefresh = function(objectTypeCode, dialogId) {
var primaryEntityId = Xrm.Page.data.entity.getId();
var rundialog = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx');
rundialog.get_query()['DialogId'] = dialogId;
rundialog.get_query()['ObjectId'] = primaryEntityId;
rundialog.get_query()['EntityName'] = objectTypeCode;
var hostWindow = window;
if (typeof(openStdWin) == 'undefined') {
hostWindow = window.parent; // Support for Turbo-forms in CRM2015 Update 1
}
if (typeof(hostWindow.openStdWin) != 'undefined') {
hostWindow.openStdDlgWithCallback(rundialog, hostWindow.buildWinName(null), 615, 480,function(){Xrm.Utility.openEntityForm(objectTypeCode,primaryEntityId)})
}
}
Everything works fine but the Case form is not reloaded after the Dialog is over. If I manually refresh the browser I can see the Case record was indeed cancelled as expected. I tried the code in Chrome and IE and nothing occurs at the end of the Dialog, I mean, the form is still opened with the old status (Active). What am I doing wrong? The CRM version is 2016 Update 1 Online but this should work in 2016 OnPremise, too.
Any suggestion would be much appreciated.
Xavier Villafuerte