This pertains to CRM 2016 on-premise implementation.
In my CRM 2016 environment, I have a customized button in the command bar that utilizes a JavaScript web resource to invoke an external asp.net page hosted on another server. This external page facilitates user-specific actions which are then exhibited on one of the subgrids within the parent page.
Below is the JavaScript code employed by the CRM button to launch the external page:
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);
// Focuses on the newWindow
if (window.focus) {
newWindow.focus();
}
}
I am seeking a method to refresh the parent CRM page to exhibit the modifications made by the asp.net page. Ideally, I would prefer refreshing only the subgrid on the parent page, but if necessary, reloading the entire page is acceptable.
I attempted utilizing a JavaScript function on the child page to trigger window.opener.location.reload() on the window unload event, however, it did not work on the parent CRM page. Additionally, I tried window.opener.parent.refreshParent(). The issue appears to be that window.opener lacks a value since the external page is not opened from the CRM page directly, but through the JavaScript function.
Is there a way to pass this value via JavaScript so that there's a value in window.opener to operate with?
Could we identify the subgrid on the parent page and send a refresh command to it?
Perhaps there exists a superior solution that has eluded me? Any suggestions for achieving this functionality are welcome.