Announcements
No record found.
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?
This should do the job.
//Close the existing open form
parent.window.close();
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 Close
Hope it helps.
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.
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.
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(); } });
Hello,
You can use "window.top.close();" as in my blog post: charlesabikhirs.blogspot.com/.../d365-html-web-resource-web-interface-vs.html
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();
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(); });
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 180 Super User 2026 Season 1
11manish 123
CU11031447-0 100