Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

UI // refresh webressource HTML

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UI // refresh webressource HTML

    Hello All,

    Thank you for your answers.

    Zak

  • Suggested answer
    Ambesh Singh Profile Picture
    Ambesh Singh 145 on at
    RE: UI // refresh webressource HTML

    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

  • Suggested answer
    Jomy Jose Profile Picture
    Jomy Jose 290 on at
    RE: UI // refresh webressource HTML

    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);

               }

  • Suggested answer
    - Matt Bayes - Profile Picture
    - Matt Bayes - 890 on at
    RE: UI // refresh webressource HTML

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UI // refresh webressource HTML

    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.

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: UI // refresh webressource HTML

    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

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans