I'm using Xrm.Navigation.openWebResource method to open HTML page.
I have a button on this page.
How can I close the window on click of this button?
I'm using Xrm.Navigation.openWebResource method to open HTML page.
I have a button on this page.
How can I close the window on click of this button?
Unfortunately, none of the answers suggested worked for me.
Finally after lots of efforts, I got it working using the following code:
Xrm.Navigation.openForm(windowOptions).then( function (success) { window.close(); });
Hi Priyank ,
If I understood correctly you want to refresh the parent page where you actually put the button to open the web resource. In this case first you need to make sure you added following reference in the web resource html <head> section to access XRM object -
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
And then write below code to refresh and the close the window -
window.parent.opener.Xrm.Page.data.refresh();
window.top.close();
Hello,
You can use "window.top.close();" as in my blog post: charlesabikhirs.blogspot.com/.../d365-html-web-resource-web-interface-vs.html
Yes, when the button is clicked on the web resource, I want to close the web resource and refresh the form.
My code looks like this:
$("#btnAddProducts").click(function () { var isCloseProductwizard = CreateOrderProducts(); if (isCloseProductwizard) { var orderID = getQueryStringValue("OrderID"); var windowOptions = { openInNewWindow: false, entityName: "salesorder", entityId: orderID }; Xrm.Navigation.openForm(windowOptions); window.top.close(); } });
Hi partner,
Did you mean you want to refresh the form when closing the web resource?
Could you show complete code and so that we could test it for you in environments.
Best Regards,
Leo
var windowOptions = { openInNewWindow: false, entityName: "salesorder", entityId: orderID }; Xrm.Navigation.openForm(windowOptions);
I'm trying to reload the entity record using the above code.
After the above code executes I'm trying to close the window.
If I comment out the above code then both parent.window.close() and window.top.close() work but when I uncomment the above code, the window is not getting closed.
Hi partner,
Please use "window.top.close()" to close the window opened by "Xrm.Navigation.openWebResource", it worked well both in UCI and classic.
After I clicked on "close", this window closed as expected.
Here's the sample code of the close button in web resource.
Close Window
Hope it helps.
Best Regards,
Leo
This should do the job.
//Close the existing open form
parent.window.close();
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,409
Most Valuable Professional
nmaenpaa
101,156