Search code examples
dynamics-crm-2011dynamics-crmmicrosoft-dynamicsjscriptdynamics-crm-online

Setting URL of an HTML Web Resource in Microsoft CRM 2011


I have placed an HTML Web Resource on my CRM Contact Form and I want to dynamically change the URL of this HTML Web Resource.

How can I set the URL of this HTML Web Resource using jScript's XRM properties? Basically I am looking for something like this:

Xrm.Page.ui.controls.get("ID of my web resource").url = "http://google.com"

I tried this and few other variants but nothing seems to work.

Note:
I am aware of the following alternate solutions for this approach but I have a specific requirement to achieve this using HTML Web Resource:
1) Using iFrame to load dynamic contents
2) By placing a JS in the HTML Web Resource's code and using location.href="my dynamic URL"


Solution

  • You need to use the setSrc method:

    Xrm.Page.getControl("new_iframe").setSrc("http://www.stackoverflow.com");
    

    MSDN reference:

    http://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_setSrc