Announcements
It appears that in the new UI the new refresh button on forms does not trigger the form load event. I can't find any event to subscribe to to deal with it either. I have a html web resource on the form that I need call javascript on when certain fields change (working) or when the refresh button is clicked (not working). If you click the refresh button then the web resource is also refreshed but I need to call javascript on it again so that it can get access to the formcontext object again.
After more debugging. I'm going to say this is NOT what is going on. The form load event is firing.
My actual issue is that on Chrome\Edge (but not on FireFox) the html web resource is getting reloaded after the form load by just a couple milliseconds. So that my code is running but then the web resource refreshes afterward. I fixed it by adding a timeout. I had thought that the getContentWindow() call would handle this, but apparently not.
I had to add the setTimeout call in the following code to make it work.
function formLoad(context)
{
var formContext = context.getFormContext();
var productOptionsIFrame = formContext.getControl('WebResource_ProductOptionPicker');
if (productOptionsIFrame) {
setTimeout(function () {
productOptionsIFrame.getContentWindow().then(function (w) {
w.RefreshOptionPicker(Xrm, formContext);
}
); // force reload
}
, 1000);
}
}
Hi Partner,
I did a simple test in my instance, I have an alert function on onLoad event on form, when click "Refresh" ribbon, the alert will also be triggered.
Did you put the javascript in your html web resource on the form and when loading the form, call the JS functions in it?
Could you kindly share your code and more details about the situation?
Regards,
Leo
André Arnaud de Cal...
294,190
Super User 2025 Season 1
Martin Dráb
232,968
Most Valuable Professional
nmaenpaa
101,158
Moderator