I found this piece of code really handy. If you have a web resource that you place inside a form and if you want to manipulate the html within that html web resource you can do it.
Xrm.Page.getControl("WebResource_YourWebResource").getObject().contentWindow.window.WebResourceFunction
The function WebResourceFunction sits inside the HTML web resource and can do anything.
An example of how I used it was to call the HTML web resource function on the onchange event of a lookup and display something different for different values in the lookup box. Oh and yes you can pass parameters to the function as well.
To be fair, I found this technique on some other blog, but I can reference it since I lost the address and can't find it any more.
Happy Coding!
Xrm.Page.getControl("WebResource_YourWebResource").getObject().contentWindow.window.WebResourceFunction
The function WebResourceFunction sits inside the HTML web resource and can do anything.
An example of how I used it was to call the HTML web resource function on the onchange event of a lookup and display something different for different values in the lookup box. Oh and yes you can pass parameters to the function as well.
To be fair, I found this technique on some other blog, but I can reference it since I lost the address and can't find it any more.
Happy Coding!
hi Atif,
ReplyDeletethanks for your post. but i created a checkbox in HTML WebResource. I want to retrieve the selected values in checkbox and place those in a CRM2011 Entity field
Hi Atif,
ReplyDeleteI tried to access function in html web resource from form JS like you described . It works but sometimes it throws an error that Object doesn’t support property or method ‘getScript’. Here getScript is a function in html web resource.
I used following script
var data = Xrm.Page.getControl(id).getObject().contentWindow.window.getScript();
Any idea of the issue.
Thanks Pradeep