Hello team,
Please, i have a question for UI.
Could you tell me how i can refresh an html webresource which exists in a tab from another tab? using javascript.
I'm available for more information.
Thank you in advance for your answers.
Zak
Hello All,
Thank you for your answers.
Zak
Hello hamd,
Simply update the iframe source url with same value, it will refresh your web resource., you can trigger on button click, or some other events too.
Thanks,
Ambesh Singh
Use the below method.
var formContext = executionContext.getFormContext();
var Id = formContext.data.entity.getId();
var globalContext = Xrm.Utility.getGlobalContext();
var clientUrl = globalContext.getClientUrl();
var control = formContext.ui.controls.get("WebResource_MultiCheque_Replacement");
var recordurl_replacement = clientUrl + "/WebResources/md_MultichequeReplacement.Html?";
params = "id=" + Id;
var mainURLReplacement = recordurl_replacement + params;
if (Id) {
control.setSrc(mainURLReplacement);
}
Hey Zak,
As mentioned, you can use the SetSrc method in order to reload the Web Resource.
The control should be accessible via Javascript from whatever tab you are in.
You would have to have some sort of code similar to this, which would be bound to the OnChange event of your field in the News tab:
/* CREATE YOUR NAMESPACE */ var Zak = window.Zak || { namespace: true }; /* EXECUTE YOUR MAIN NAMESPACE FUNCTION */ (Zak.Contact = function() { /* CREATE METHOD FOR ON CHANGE OF YOUR FIELD */ Zak.Contact.Field_OnChange = function(executionContext) { /* RETRIEVE THE FORM CONTEXT */ var formContext = executionContext.getFormContext(); /* RETRIEVE THE WEB RESOURCE URL FROM THE NAME */ var webResourceName = "zak_mywebresource"; var webResourceUrl = formContext.getControl(webResourceName).getSrc(); /* VERIFY WEB RESOURCE URL COULD BE FOUND */ if (webResourceUrl) { /* ASSIGN URL OF WEB RESOURCE TO THE SAME URL */ formContext.getControl(webResourceName).setSrc(webResourceUrl); } }; })();
Using the code above (or something similar) you can bind the function to the On Change event of your desired field and reload your web resource.
Just make sure when binding to the On Change event you check the box for "Pass Execution Context as First Parameter" so that the Form Context can be resolved.
If you have questions please let me know!
If this solved your issue, I'd appreciate if you could set this question as answered!
Thanks!
Matt Bayes
Thank you Davide for your answer.
Yes, I do use the setSRC method.
I want to force the update of my webresource in the "resume" tab following the update event of a field in the "News" tab.
Otherwise, I have to manually select the "Resume" tab for the web resource to update.
You should be able to do this by using the setSrc method. If you set the src to be the same as it already is, the webresource should reload. Note that you may need to include Meta tags in your html webresource to prevent it from being cached
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156