locked
Refreshing a Web Resource on a form - CRM 2011 RRS feed

  • Question

  • Hi guys, just wondering if there's any way to refresh a web resource on a form in CRM 2011. At the moment I have two HTML web resources, both with drop down boxes that populate with data. The 2nd drop down list needs to update its contents dependant on the selected option of the first drop down in the first web resource.

     

    To do this I tried to add an onChange event to a text field on the form (The value of the selected option in the first drop down list is posted here and updated whenever a new option is selected). Attached to this I need a script that prompts the 2nd web resource to refresh so it will populate itself with data relevant to the newly selected option. How would I go about doing this in code? I've tried something along the lines of Xrm.Page.getControl('webresource').refresh() but that seems to only apply to data grids.

     

    Thanks in advance for any advice

     

    - CR



    Friday, September 2, 2011 9:26 AM

All replies

  • I don't believe there is a native way to refresh the web resource.  One option would be to add javascript to your html page and create a Refresh method that your javascript on the CRM form will call.
    Blake Scarlavai - http://mscrmdev.blogspot.com/ - Sonoma Partners - http://www.sonomapartners.com/
    Monday, September 5, 2011 5:43 PM
  • You don't specify why the web resource needs to be refreshed.  Usually a web resource represents static content only.  If there is new data you need to add and have persisted, the best way is probably through a custom entity.  If you are just looking to have one drop-down drive the content of another check out this blog:

    http://blog.sonomapartners.com/2011/06/simple-javascript-to-create-dynamic-cascading-picklists-in-microsoft-crm-2011.html

    -JayB

    Tuesday, September 6, 2011 1:00 PM
  • I know this is an old post, but I thought I would post this to help someone out as I wanted to achieve the same thing.

    How I refresh a html web resource is as follows in a form's OnChange event is as follows.

    var someOnchangeEvent = function(){
        var wrControl = Xrm.Page.ui.controls.get("nameofwebresoucecontrol");
        wrControl.setSrc(wrControl.getSrc());
    }

    This reloads the the html page and the javascript within it fires to show relevant information. 

    Thursday, October 4, 2012 8:31 AM
  • Thanks Fire.Storm

    Works very well.

    And as to why I need it.  I have a webresource which I use to display related information from other entities.

    Cheers

    Paul


    • Edited by Paul C Mitton Wednesday, November 7, 2012 6:40 PM Spelling
    Wednesday, November 7, 2012 6:40 PM
  • Thursday, November 8, 2012 6:43 AM
  • hi,

    You can achieve it by assigning the value of that variable in one hidden field. (e.g. <input type="hidden" id="hiddenVariable" />)

    And then, retrieve the value from that hidden field with the following code. (replace "WebResource_HTMLPage" with your webresource name)

    Xrm.Page.getControl("WebResource_HTMLPage").getObject().contentWindow.document.getElementById("hiddenVariable").value

    Another way is that you can also set the value into the temporary field of CRM from the webresource.

    parent.Xrm.Page.getAttribute("new_temp").setValue(variableValue);
    Friday, November 9, 2012 12:34 PM
  • I had to make this simple modification to get it to work:

    function RefreshWR(){

    var wrcontrol = Xrm.Page.ui.controls.get("nameofwebresoucecontrol");
     wrcontrol.getSrc();
    }


    Jane Davis

    Friday, November 30, 2012 5:46 PM