Web resources are a great step forward and were introduced in Microsoft Dynamics CRM version 2011.
Web resources are a great way to act as a container. Web resource can store a piece of JScript code, image, etc.
Web resources are virtual files which are always stored in the Dynamics CRM 2011 database. This is beneficial as we don't have to worry about the physical files and their locations.
Web resources have a unique path and can be accessed through that URL. This is beneficial as we can use the URL in our code.
There are the following kinds of web resources:
- JScript
- XML
- XSL
- Image (types are ICO, PNG, JPG, GIF)
- HTML
- CSS
- Data
- Silverlight
The 3 most widely used types are JScript, HTML and Image. Read my blog for more information on Script (JScript) Web Resources.
In this blog I will show how to create and use an image web resource.
Image web resources are the container for the images in ICO, PNG, JPG or GIF format. Image web resources can be used for:
- Custom Entity Icons
- Display images on the Entity Forms
- Icons for Custom Ribbon Buttons
- Icons for Site Map
In this blog I will create an Image web resource to store a JPG image. I will include this image on an entity form.
1) I have an entity called "Movies". I have few movie records.
"Movies" Entity and Records |
2) In the movie entity record, I want to place an image on top of the form. This image will be the same for every movie entity record. Below I have shown the area where I would be displaying the image.
Movie Record "Pirates of the Caribbean: On Stranger Tides" |
3) I have an image which I would like to display on every form.
Image to be Displayed on Every Movie Form |
4) I will create a web resource. I will go to my "Movies" solution.
"Movies" Solution |
5) I will go to the "Web Resources" component inside the solution.
"Web Resources" component inside the Solution "Movies" |
6) I will create a new web resource called "Movies Header Image". I have selected the "Type" as "JPG format". This means this web resource is of type image and format is JPG. Click "Save".
Movies Header Image Web Resource |
7) The web resource is created. There is a unique URL created for this web resource. This means the image can be accessed through this web resource URL.
By creating an image web resource, we are making sure that this image is available to Dynamics CRM 2011 for use.
The URL created here is:
http://crm2011:5555/AshishMahajan/WebResources/new_Movies.HeaderImage.
8) Publish this web resource. We need to publish the web resource to make it available. After publishing I can start using the web resource in my "Movies" entity form.
By creating an image web resource, we are making sure that this image is available to Dynamics CRM 2011 for use.
The URL created here is:
http://crm2011:5555/AshishMahajan/WebResources/new_Movies.HeaderImage.
Movies Header Image Web Resource Created |
Publish Web Resource |
Movie Entity in the Solution |
Open the Main Information Form for the "Movies" Entity |
Insert Web Resource |
Web Resource Properties |
Web Resource Control Created |
Go to "Home" tab. Click "Save and Close".
Drag the Web Resource Control to the Top of Movie Name Field |
Publish the Movie Entity |
Movie - Pirates of the Caribbean On Stranger Tides |
Movie - Skyfall |
Movie - The World Is Not Enough |
I hope this blog about 'Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Image (PNG, JPG, GIF, ICO) Web Resources' was informative. Please feel free to leave your comments.