One of the interesting new capabilities in Dynamics CRM 2011 is the ability to imbed HTML web pages in the CRM form, thus providing a means of presenting data and controls to the user that transcend the limitations of the basic CRM form, using tools and skills that are simpler and easier to deploy than Silverlight. Web Page web resources are similar to the traditional IFRAMEs used in previous releases of Dynamics CRM, but there are some notable differences, namely:
· Code – Web Page web resources can only contain code that can be executed on the client such as HTML and Jscript. They cannot use ASP.NET pages.
· Rendering – Web Page web resources are rendered on the client as opposed to IFRAMEs which are rendered on the server.
· Properties and Methods – Most of the properties and methods of the Web Page web resources are the same as those of the IFRAME, with the exception of the IFRAME’s getInitialURL method.
· Events – The Web Page web resource does not have an equivalent of the IFRAME’s OnReadyStateComplete Event.
· Deployment – Web Page web resources are automatically deployed to the Dynamics CRM Outlook client and are able to render even if the client is offline or disconnected (assuming that the web page does not use external references).
· Solutions – Unlike the code for IFRAME-displayed web page which resides outside of CRM, the code for Web Page web resources is stored within Dynamics CRM and can be managed as part of a solution.
When getting started with Web Page web resources, here are some things to consider:
· Passing Parameters – Standard IFRAME parameters such as entity and contextual metadata are passed automatically to the Web Page web resource if the option is selected on the web resource property form.
· Passing Optional Parameters – The Web Page web resource only permits the passing of a single optional parameter named ‘data’. In order to pass multiple parameters, the name-value pairs must be concatenated, encoded using the encodeURIComponent method, and appended to the web resource source using the setSrc method.
· Modifying the Web Resource – The SDK cautions that the form OnLoad event should not be used to modify a Web Page web resource as variances in processing could cause these changes to be overwritten by the web resource’s default values. There are two recommended approaches to get around this issue, and which you choose will be based upon the application behaviors you are trying to enforce:
1. OnChange – use the onChange event for a form control to set the source property for the web resource when the data in the control changes.
2. TabStateChange – use the TabStateChange event for a tab to set the source property when the display state changes.
Note that it is extremely helpful to encode much of the web resource supporting functions into JScript libraries (also web resources) that can then be referenced from the Web Page web resource and managed as part of the solution.