Posted on 8. September 2011

Calling a function in an HTML Web Resource from another JavaScript Web Resource

 

If you have a field value on an entity form that an Html Web Resource is dependant on, you might have the following in your onload event of the Html Web Resource:

var crmForm = window.parent.Xrm.Page;
var lookup = crmForm.getAttribute("customerid").getValue();
if (lookup != null) customerid = lookup[0].id;

 

If so, will need to ensure that when this value changes, you update the values displayed on the html web resource. Rather than simply re-loading the web resource, it's going to be better for the user if you create a function to update the values without it blanking and re-loading.

You can do this by implementing a function in your html web resource and then calling it from the onchange event of the dependent field:

Xrm.Page.getControl("WebResource_<Name>").getObject().contentWindow.window.fooBar();

Hope this helps.

 

Comments

Comments are closed