Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Refreshing the Web Resource in Dynamics 365

(1) ShareShare
ReportReport
Posted on by 17,074

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.

1768.3.png
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

  • Suggested answer
    Faizal Profile Picture
    Faizal 545 on at
    RE: Refreshing the Web Resource in Dynamics 365

    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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refreshing the Web Resource in Dynamics 365

    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);
  • Antheny Yu Profile Picture
    Antheny Yu 20 on at
    RE: Refreshing the Web Resource in Dynamics 365

    I added a timeout to the function and it was able to refresh properly.

    setTimeout(function () {

      webr.setSrc(src);

    },100);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refreshing the Web Resource in Dynamics 365

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Refreshing the Web Resource in Dynamics 365

    Hi,

    Does anyone know a solution for Unified Interface? What is provided here works on classic interface but not Unified Interface

  • Robert_K Profile Picture
    Robert_K 25 on at
    RE: Refreshing the Web Resource in Dynamics 365

    If you find the answer as useful, please mark it as verified.

  • Robert_K Profile Picture
    Robert_K 25 on at
    RE: Refreshing the Web Resource in Dynamics 365

    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.

    5554.Firefox-Developer-Edition.png

  • acraigx Profile Picture
    acraigx on at
    RE: Refreshing the Web Resource in Dynamics 365

    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.

  • Seenivasan M Profile Picture
    Seenivasan M 305 on at
    RE: Refreshing the Web Resource in Dynamics 365

    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.

  • Seenivasan M Profile Picture
    Seenivasan M 305 on at
    RE: Refreshing the Web Resource in Dynamics 365

    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.

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans