/ Published in: JavaScript
How to launch custom dialog from JavaScript (for example from custom RibbonButton)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function launchModalDialog(dialogId, typeName, recordId) { // Server Url var serverUrl = Xrm.Page.context.getServerUrl(); // Sanitize RecordId recordId = recordId.replace("{", ""); recordId = recordId.replace("}", ""); // Sanitize DialogId dialogId = dialogId.replace("{", ""); dialogId = dialogId.replace("}", ""); // Create Url var serverUri = serverUrl + '/cs/dialog/rundialog.aspx'; var dialogUri = serverUri + '?DialogId=%7b' + dialogId.toUpperCase() +'%7d&EntityName=' + typeName + '&ObjectId=%7b' + recordId + '%7d'; window.showModalDialog(dialogUri); // Reload form window.location.reload(true); }