Question

I have just created a Ribbon button and pointed it to a webresource js. However my code doesnt seem to launch my dialog. Any pointers would be very much appreciated.

function TestRibbon(sLeadID) 
{
var DialogGUID = "6D128DF9-F51A-4D97-912D-C5A1FA4CEAFB";
var serverUrl = "https://xxx.xxx.co.uk:444/";
serverUrl = serverUrl + "cs/dialog/rundialog.aspx?DialogId=" + "{" + DialogGUID + "}" +    "&EntityName=lead&ObjectId=" + sLeadID;
PopupCenter(serverUrl, "mywindow", 400, 400);
window.location.reload(true);
 }

function PopupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var targetWin = window.showModalDialog(pageURL, title, 'toolbar=no, location=no,     directories=no,   status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
Was it helpful?

Solution

Your server URL is static. Use this code that generates URL dynamically, also with new release we figured out that URL with status=no is not opening correctly, so we started to use status: no and it became to work as expected. See the following code:

function TestRibbon(sLeadID) {
    var DialogGUID = "6D128DF9-F51A-4D97-912D-C5A1FA4CEAFB";
    // Get the CRM URL 
    var serverUrl = Xrm.Page.context.getServerUrl();

    // Cater for URL differences between onpremise and online 
    if (serverUrl.match(/\/$/)) {
        serverUrl = serverUrl.substring(0, serverUrl.length - 1);
    }

    serverUrl = serverUrl + "/cs/dialog/rundialog.aspx?DialogId=" + "%7b" + DialogGUID + "%7d" + "&EntityName=lead&ObjectId=" + sLeadID;
    PopupCenter(serverUrl, "mywindow", 600, 500);
    window.location.reload();
}

function PopupCenter(pageUrl, title, w, h) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    window.showModalDialog(pageUrl, title, 'status:no; scroll:no; resizable:no; dialogWidth: ' + w + 'px; dialogHeight: ' + h + 'px; dialogTop: ' + top + 'px; dialogLeft: ' + left + 'px;');
}

During investigation found this post for Ribbon Workbench for CRM 2011 Solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top