0

我刚刚创建了一个功能区按钮并将其指向一个 webresource js。但是我的代码似乎没有启动我的对话框。任何指针将不胜感激。

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);
}
4

1 回答 1

0

您的服务器 URL 是静态的。使用这个动态生成 URL 的代码,同样在新版本中,我们发现 URLstatus=no没有正确打开,所以我们开始使用status: no它并按预期工作。请参阅以下代码:

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;');
}

在调查过程中发现这篇文章针对 CRM 2011 解决方案的 Ribbon Workbench

于 2013-09-27T08:52:41.433 回答