【发布时间】:2016-07-19 14:49:55
【问题描述】:
这是针对 CRM 2016 内部部署的。
我在 CRM 2016 的命令栏中有一个自定义按钮,它使用 javaScript Web 资源来调用位于另一台服务器上的外部 asp.net 页面。此外部页面允许用户执行一些自定义操作,然后这些操作将显示在父页面的子网格之一上。
这是 CRM 按钮用来打开外部页面的 javascript。
function openPricingForm() {
var loc = Xrm.Page.context.getClientUrl();
var pl = Xrm.Page.getAttribute('pricelevelid').getValue();
var id = Xrm.Page.data.entity.getId();
var type = Xrm.Page.data.entity.getEntityName();
var url = 'http://app.domain.com/customPage.aspx?pl='+ pl[0].id +'&id='+ id + '&type=' + type + '&loc=' + loc;
var title = 'Select Products';
var w = 500;
var h = 600;
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
top = top - (top * 0.25);
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
我需要能够刷新父 CRM 页面以显示 asp.net 页面所做的更改。我宁愿只刷新父页面上的子网格,但如果必须,我可以只重新加载整个页面。
我尝试在子页面上使用 javascript 函数在窗口卸载事件上调用 window.opener.location.reload(),但它在父 CRM 页面上不起作用。我也尝试过 window.opener.parent.refreshParent()。我认为问题在于 window.opener 不包含值,因为外部页面没有被 CRM 页面打开,它是由 javascript 函数打开的。
有没有办法通过 javascript 传递这个值,以便我在 window.opener 中有一个值可以使用?
有没有办法识别父页面上的子网格并向其发布刷新命令?
也许我缺少更好的解决方案?我愿意接受任何有关如何使其发挥作用的建议。
【问题讨论】:
标签: javascript asp.net crm microsoft-dynamics dynamics-crm-2016