Share via


Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Image (PNG, JPG, GIF, ICO) Web Resources

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.

http://4.bp.blogspot.com/-0s9apy28R4s/UUUtYX_p4rI/AAAAAAAABBU/Or5jYrtfoS4/s640/Movie+Records.JPG

"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.

http://1.bp.blogspot.com/-1haygPM_5RE/UUU37CeQRXI/AAAAAAAABBk/KznFcarwc-c/s640/Movie+Record.JPG

Movie Record "Pirates of the Caribbean: On Stranger Tides"

3) I have an image which I would like to display on every form.

http://2.bp.blogspot.com/-uQ_INPOeIM4/UUU5S0bOhYI/AAAAAAAABBs/xlTstiT6nBg/s1600/Image+Displayed+on+Every+Movie+Form.JPG

Image to be Displayed on Every Movie Form

4) I will create a web resource. I will go to my "Movies" solution.

http://4.bp.blogspot.com/-NWvVgWbidZ0/UUU6K79WPbI/AAAAAAAABB0/xNHZjHNsCIM/s1600/Movies+Solution.JPG

"Movies" Solution

5) I will go to the "Web Resources" component inside the solution. 

http://3.bp.blogspot.com/-0ZiLGXUlJKU/UUU6yno4YTI/AAAAAAAABB8/SOx_0Q1OQHI/s1600/Web+Resource.JPG

"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".

http://4.bp.blogspot.com/-nn6Xq4m9qSo/UUU7scafEpI/AAAAAAAABCE/UDp3zGg_JjU/s640/Movies+Header+Image+Web+Resource.JPG

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.

http://1.bp.blogspot.com/-khYyRTXsVS4/UUWYqMthy9I/AAAAAAAABCU/8DaqTEfZDrM/s640/Movies+Header+Image+Web+Resource+Created.JPG

Movies Header Image Web Resource Created

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.

http://4.bp.blogspot.com/-TwCq6GwUggw/UUWauImBCkI/AAAAAAAABCk/8-do3YCthuI/s640/Publish+Web+Resource.JPG

Publish Web Resource

9) I will go to "Movies" entity form and insert this web resource. The "Movies" entity is under the Entities component in the solution.

http://2.bp.blogspot.com/-ody0VgP3dQc/UUWcywwXAaI/AAAAAAAABC0/vJCZaep-HQ8/s640/Movie+Entity+in+the+Solution.JPG

Movie Entity in the Solution

10) Open the main information form for the "Movies" entity.

http://4.bp.blogspot.com/-_MGWdnv18qo/UUWf1QtWnLI/AAAAAAAABDE/kihe0HsRWNQ/s640/Open+the+Main+Information+Form.JPG

Open the Main Information Form for the "Movies" Entity

11) Click on the "Insert" tab on the form. Here we have the option to add a "Web Resource". Click on the ribbon button "Web Resource".

http://2.bp.blogspot.com/-K71MpANophc/UUWux8ke03I/AAAAAAAABDU/k3wfhRMWL2Y/s640/Insert+Web+Resource.JPG

Insert Web Resource

12) I have entered the following properties for this web resource. I have selected the image web resource; I created above in the field "Web resource". Click "OK".

http://3.bp.blogspot.com/-h1F67QP7_Uk/UUWxAJ2clnI/AAAAAAAABDg/sSRnOm-E_Hk/s1600/Web+Resource+Properties.JPG

Web Resource Properties

13) This will place a control at the end of the section (which is selected).

http://4.bp.blogspot.com/-p7TSWoV2CvY/UUWxwhzYnwI/AAAAAAAABDs/3QS9hMbLqOA/s640/Web+Resource+Control+Created.JPG

Web Resource Control Created

14) Since I want to display this control on the top, so I will drag it to the top of "Movie Name" field.

Go to "Home" tab. Click "Save and Close".

http://1.bp.blogspot.com/-dAJPe1EZ7gE/UUWzW1Ktc5I/AAAAAAAABD4/CZBQ-31BgU8/s640/Drag+the+Web+Resource+Control+to+the+Top+of+Movie+Name+Field.JPG

Drag the Web Resource Control to the Top of Movie Name Field

15) Publish changes to the "Movie" entity.

http://4.bp.blogspot.com/-Fkw0Uhc-vb4/UUW0l2bOPdI/AAAAAAAABEE/7cHx95wh3vw/s1600/Publish+the+Movie+Entity.JPG

Publish the Movie Entity

16) The web resource will be displayed on all the "Movie" entity records. Below, shown, are 3 movie record examples displaying this image.

http://4.bp.blogspot.com/-XBxFUGpb1S4/UUW2E85fhfI/AAAAAAAABEM/LGlI2j2zufg/s640/Movie+-+Pirates+of+the+Caribbean+On+Stranger+Tides.JPG

Movie - Pirates of the Caribbean On Stranger Tides

http://2.bp.blogspot.com/-1_cl7FksXvw/UUW2uy8OgyI/AAAAAAAABEU/vAjI1ZWBYno/s640/Movie+-+Skyfall.JPG

Movie - Skyfall

http://2.bp.blogspot.com/-oEUKaqaGz6s/UUW3DH-LcPI/AAAAAAAABEc/WtxwxJDAST0/s640/Movie+-+The+World+Is+Not+Enough.JPG

Movie - The World Is Not Enough

I have used this blog to create and display an image web resource on an entity form. You can very well display it as a custom ribbon button icon or a site map icon or a custom entity icon.

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.