Microsoft Dynamics CRM Web Resources

Another client-side tool for extending Microsoft Dynamics CRM is through the use of web resources. Microsoft Dynamics CRM web resources are “web” files that are stored within CRM that contain content that is useful for integrating web page functionality into the Microsoft Dynamics CRM interface.

The simplest example of a web resource is an image file. You can store an image in CRM as a web resource and use the image on forms or other user interface elements throughout the system.

One of the more complex examples of a web resource is a Silverlight application. You can build a robust Silverlight application that reads the context of the users and/or entity, access data from entities, and extend the functionality of the system.

Because web resources are stored within the Microsoft Dynamics CRM database, they can be reused throughout the system in different forms or entities and can be deployed using Solutions.

The following are the most common types of Web Resources within Microsoft Dynamics CRM along with their common usage and implementation:

Web Pages or Style Sheets

An HTML web resource allows a developer to imbed custom HTML code on forms that extend either the presentation and/or functionality of the form. Style sheets can be uploaded as a web resources as well, and used by HTML pages to more efficiently update the appearance of the web page.

The HTML can be used to display a single HTML control, like a custom drop list; or it can contain an entire page of data controls that collect a larger collection of data.

While HTML pages can be added to CRM as a web resource, the HTML cannot include code that requires server processing. All code must run on the user’s client browser.

HTML pages can access another type of web resource, Javascript libraries, and interact with the CRM web services to utilize data lookups or updates. In addition, an HTML web resource is allowed to accept one incoming parameter within a query string called “Data”.

A common example of an HTML web resources is that of a custom drop list. Microsoft Dynamics CRM includes an out of the box field for “State or Province” which displays as a single text box for manual entry, but it is not a drop list of State or Province options, which is common. As such, it is a common need to extend CRM by building an HTML web resource that consists of a single drop list control that is populated with a custom list of states or provinces. When selected, some Javascript saves the selected value into the out of the box “State or Province” field as a line of text.

Javascript (Jscript)

A Javascript Web Resource allows a developer to create libraries of common Javascript functions that can become available globally throughout CRM. These libraries are then exposed, most commonly to CRM forms, where you can configure event handlers on the form to call specific functions within the library. The libraries can also be accessed by ribbon commands or other web page web resources.

Example: HTML State Droplist and Javascript to store in OOB state field.

XML Data

Data can be stored within a web resource in XML format. While this technique can be used as a method to cache data, it is not recommended. Often the XML web resource is used to store static settings or configuration data, then accessible by parsing the XML for setting values.

Images

Common web image types (jpg, gif, png, and ico) can be stored in CRM as a web resource, which then allows a developer or customizer to display that image in various locations. For example:

  • Use an image as an icon for ribbon buttons/controls, site map nodes
  • Images used to identify form/entity
  • Display images on an HTML or other web page web resource for backgrounds or identifiers.

Silverlight

Microsoft Dynamics CRM supports and hosts compiled Silverlight applications as an option for presenting a more robust user interface that can handle a richer dataset than CRM forms.

When developing a Silverlight application, CRM will commonly pass to the application the context of the data and user. In addition, the Silverlight application can use CRM’s Organization Data Service (an oData service exposed via a REST-based) to work with additional related data outside of the context that was passed to it.

You can present a Silverlight resources as an imbedded object on a CRM form or it can be presented within a host HTML page (also a CRM web resource). Because Silverlight is a client-side resource, it offers speed, performance, and flexibility when extending CRM.