Hi All,
I am trying to refresh the HTML web resource on the form on change of a field (date time field) in dynamics 365. I used the code below.
var webResource = Xrm.Page.ui.controls.get("WebResource_OnlineMeetingForm"); webResource.setSrc(webResource.getSrc());
But it's not working.
The screenshot of the form is shown below.
On the change of the start time field (date time field), I need to refresh the table (HTML web resource) and display the meetings on that date.
How shall I do this?
Any help is appreciated.
*This post is locked for comments
For UCI, you can try somthing like below.
var webResourceControl = Xrm.Page.getControl( "WebResource_page");
let src = webResourceControl.getObject().src;
webResourceControl.getObject().src = "about:blank";
webResourceControl.getObject().src = src;
reference: https://github.com/MicrosoftDocs/dynamics-365-customer-engagement/issues/912
Here is some code that works also on UCI:
var formContext = executionContext.getFormContext(); var webResArea = formContext.ui.controls.get("web resource name"); var src = webResArea.getSrc(); var url = src.substring(src.indexOf("/WebResources")); var n = url.indexOf("&dt="); if (n > 0) url = url.substring(0, url.length - n + 1); var dt = Date.now(); if (url.indexOf("?data") > 0) url += encodeURIComponent('&dt=' + dt); //unified interface else url += '?data=' + encodeURIComponent('dt=' + dt); //classic interface webResArea.setSrc(url);
I added a timeout to the function and it was able to refresh properly.
setTimeout(function () {
webr.setSrc(src);
},100);
Hi, I too have the same problem, though the above solution is working like a charm in Web client, the same is not working for UCI. Any help is much appreciated.
Hi,
Does anyone know a solution for Unified Interface? What is provided here works on classic interface but not Unified Interface
If you find the answer as useful, please mark it as verified.
Try this
function refreshWebResource(executionContext, WebRrscName) {
var _crmForm = executionContext.getFormContext();
var webResource = _crmForm.getControl(WebRrscName);
if (webResource != null) {
var webResourceSrc = webResource.getSrc();
webResource.setSrc(null);
webResource.setSrc(webResourceSrc);
}
}
on form field event handling
check execution context as first argument and set "WebResource_YOURNAME" as second argument.
Does this work in v9.0? I had the same code working in 8.2 but now it appears to be failing. I assume this needs to be rewritten using executionContext.
Hi Nithya,
Its working when i place the web resource inside the form.But my Html web resource placed inside form header and its giving null value. Anything needs to be added if web resource placed inside Header?
Thank.
Hi Nithya,
Thanks for your response.
Yes. I have prepended "WebResource_" with my Web resource Name.
Ex: WebResource_test
But, I am getting null value.
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156