Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Web Resource not getting refreshed in crm 2016

Posted on by 675

Hi All,

I have 1 web resource and I show some records in it. Upon creation / deletion of records externally; the web resource will show the current state. So i have added a 'refresh' icon on that web resource that gives call to the below function.

<a title="" class="plus" id="refreshAll" style="margin-right: 5px;" onclick="RefreshWebResource();" href="javascript:;"></a>

function RefreshWebResource() {

var webResourceControl =Xrm.Page.getControl('WebResource_ProductPrice');
var src = webResourceControl.getSrc();
//webResourceControl.setSrc(null);
//webResourceControl.setSrc(src);
src = src + "%26reload%3dyes";
webResourceControl.setSrc(src);
}

but the web resource is not getting refreshed. Upon refreshing the whole page by pressing F5, it works. But I want to only refresh the web resource.

Any pointers please.

Regards,

Prashant

*This post is locked for comments

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Web Resource not getting refreshed in crm 2016

    Hey Clement,

    Adding Parent.Xrm did the thing. :)

    var webResourceControl =parent.Xrm.Page.getControl('WebResource_ProductPrice');

    var src = webResourceControl.getSrc();

    webResourceControl.setSrc(null);

    webResourceControl.setSrc(src);

    }

    Thanks a lot Clement. :)

    - Prash

  • Verified answer
    Clem Profile Picture
    Clem 2,541 on at
    RE: Web Resource not getting refreshed in crm 2016

    does you javascript is embedded into an html file ?

    Then you need to make sure that you call the parent.Xrm ...

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Web Resource not getting refreshed in crm 2016

    Hi Clement,

    var webResourceControl =Xrm.Page.getControl('WebResource_ProductPrice');

    var src = webResourceControl.getSrc(); ------------- Exception

    Uncaught TypeError: Cannot read property 'getSrc' of null

       at RefreshWebResource (ProductPrice.htm:282)

       at HTMLAnchorElement.onclick (ProductPrice.htm:90)

    This is the exception that was caught.

    Why my webResourceControl is null I am not able to understand that? :(

    -Prash

  • Suggested answer
    Clem Profile Picture
    Clem 2,541 on at
    RE: Web Resource not getting refreshed in crm 2016

    Hi,

    What about the ootb refresh function ?

    Xrm.Page.getControl(arg).refresh() msdn.microsoft.com/.../gg334266.aspx

    (sorry this is for subgrid, i answered too fast ...)

    What if you set the control to null first and then push the new src ?

    Clément

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans