Web resources for Microsoft Dynamics CRM
Applies To: CRM 2015 on-prem, CRM Online
Web resources are virtual files that are stored in the Microsoft Dynamics CRM database and that you can retrieve by using a unique URL address.
Capabilities of web resources
Web resources represent files that can be used to extend the Microsoft Dynamics CRM web application such as html files, JScript, and Silverlight applications. You can use web resources in form customizations, the SiteMap, or the application ribbon because they can be referenced by using URL syntax.
The URL syntax for web resources allows for relative path references. With your development tools, you can create a group of interdependent files on a development server by using file types compatible with web resources. Then, if you use a consistent naming convention and relative path references, the website will function after you upload all the files into Microsoft Dynamics CRM.
Because web resources are stored in Microsoft Dynamics CRM and are solution components, they can be easily exported and installed to on-premises deployments of Microsoft Dynamics CRM or to Microsoft Dynamics CRM Online. Web resources are also available to users of Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access when offline because they are synchronized with the user's data.
You can use the form editor to add and configure form-enabled web resources into your entity forms.
Because web resources are stored as records in the database, they can be managed programmatically by using the standard techniques to create, retrieve, and update records. Text-based web resources (JScript, CSS, XML, XSL, and HTML) can be edited and saved in the application.
Limitations of web resources
There is no type of web resource that supports the capabilities of an ASP.NET(.aspx) page to execute code on the server. Web resources are limited to static files or files that are processed in the browser. A web resource can contain code that is processed in the browser to execute web service calls to interact with Microsoft Dynamics CRM data. For more information, see Use web service data in web resources (OData and Modern app SOAP endpoint),
Web resources are only available by using the Microsoft Dynamics CRM web application security context. Only licensed Microsoft Dynamics CRM users who have the necessary privileges can access them.
The maximum size of files that can be uploaded is determined by the Organization.MaxUploadFileSize property. This property is set in the Email tab of the System Settings in the CRM application. This setting limits the size of files that can be attached to email messages, notes, and web resources. The default setting is 5 MB.
Web resource types
You can use ten file formats to create web resources. The following table lists each file format, the allowed file extensions, and the type value that you use for each.
Style Sheet (CSS)
Reference web resources
There are several methods that you can use to reference web resources.
You should always use the $webresource directive when referencing a web resource from a ribbon control or from a SiteMap sub area. Use the $webresource directive anywhere the XML allows a URL value. The following sample shows how to use it.
|When using the $webresource directive, Microsoft Dynamics CRM will create or update solution dependencies.|
The Xrm.Utility.openWebResource function will open an HTML web resource in a new window with parameters to pass the name of the web resource, any query string data to be passed in the data parameter, and information about height and width of the window.
The URL generated includes the unique GUID token so that the cached web resource will be loaded.
When referencing a web resource from areas that do not support using the $webresource: directive, a relative URL can be used. To enable this, we recommend that you use a consistent naming convention for the web resources that reflect a virtual file structure. The solution publisher’s customization prefix will always be included as a prefix to the name of the web resource. This can represent a virtual ”root” folder for all web resources added by that publisher. You can then use the forward slash character (/) to simulate a folder structure that will be honored by the web server.
From another web resource, you should always use relative URLs to reference each other. For example, for the web page web resource
new_/content/contentpage.htm to reference the CSS web resource
new_/Styles/styles.css, create the link as follows:
For the web page web resource
new_/content/contentpage.htm to open the webpage web resource
isv_/foldername/dialogpage.htm, create the link as follows:
Do not use a relative URL using the WebResources folder as the root path for the URL. For example, do not use this: |
The following sample shows the style of URL you can use to view web resources.
<Microsoft CRM URL>/WebResources/<name of web resource>
The application will process this URL and return the file that contains the latest version of the web resource. This URL will look like this:
<Microsoft CRM URL>/%7B<GUID value>%7D/WebResources/<name of web resource>
The GUID value is updated when you publish customizations and ensures that the browser uses the latest cached version of the web resource. Because of this, use a relative path to a web resource, the Xrm.Utility.openWebResource function, or the $webresource Directive (when possible) because the GUID value will automatically be included. For large web resources such as Silverlight web resources, there can be significant performance implications if you don’t use the cached version of the file.
The following sample shows a URL for Microsoft Dynamics CRM Online, where MyOrganization is the name of your organization, and new_/test/test.htm is the name of the web resource:
|Including the ‘/’ character and a file name extension in the name of the web resource is an optional best practice.|
The following sample shows a URL for on–premises Microsoft Dynamics CRM, where myServer is the server name:
When you write code to reference a web resource that will need to work for either Microsoft Dynamics CRM Online or on–premises Microsoft Dynamics CRM, you should use the getClientUrl function.
TasksSample: Pass multiple values to a web resource through the data parameter
Create accessible web resources
Webpage (HTML) web resources
Silverlight (XAP) web resources
Script (JScript) web resources
Image (JPG, PNG, GIF, ICO) web resources
Stylesheet (XSL) web resources
Data (XML) Web resources
CSS web resources
WebResource entity messages and methods
Other ResourcesWrite client application extensions
Sample: Web resource utility
Sample: Import files as web resources
Use web service data in web resources (OData and Modern app SOAP endpoint)
Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.