我刚刚创建了一个Ribbon按钮并将其指向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);
}
答案 0 :(得分:0)
您的服务器网址是静态的。使用此代码动态生成URL,同时在新版本中我们发现status=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;');
}
在调查过程中发现了this post
的Ribbon Workbench for CRM 2011 Solution