【问题标题】:Refresh Parent CRM Page after child ASP.net page closed子 ASP.net 页面关闭后刷新父 CRM 页面
【发布时间】: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


    【解决方案1】:

    我不知道 window.postMessage 是否适用于 Windows,但您可以调查一下。

    另一种选择是将子页面加载到 iframe 覆盖中,而不是在新窗口中加载。那么你肯定可以使用 postMessage 并且用户体验会更好。

    【讨论】:

    • 感谢您的回复,我将查看 window.postMessage 并查看它是否有用。我确实尝试创建一个 html 包装器来 iframe 我的子页面,但它破坏了表单上的 AJAX 更新面板。我有一个下拉列表,然后根据选择填充一个列表框,然后是第二个列表框,显示来自前一个列表框的选择。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-19
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    相关资源
    最近更新 更多