Chapter 5. Using Web Resources in Microsoft CRM 2011

In this chapter we are going to discuss web resources. We will learn how we can create and associate web resources to Microsoft CRM 2011 entities. Web resources are a new feature added in Microsoft Dynamics 2011. We will learn about different types of web resources available in Microsoft CRM 2011 and how we can create Silverlight applications in Visual Studio 2010. We will also learn how we can deploy Silverlight web resources in Microsoft CRM 2011.

In this chapter we will cover the following topics:

  • Understanding web resources in Microsoft CRM 2011
  • Creating web resources in Microsoft CRM 2011
  • Attaching a web resource to Microsoft CRM 2011 entities
  • Creating a sample application using Bing Map Silverlight Control
  • Introduction to Silverlight
  • Introduction to Bing Maps
  • Deploying the Silverlight application in Microsoft CRM 2011
  • Introduction to dashboards in Microsoft CRM 2011
  • Testing our application

Understanding web resources in Microsoft CRM 2011

Web resources in Microsoft CRM 2011 is a new feature; using a web resource we can share one resource with multiple entities. When we create a web resource, it is stored locally in the server and can be used in multiple entities. Web resources can be easily imported and exported from one environment to another within a solution. We can create different types of web resources as follows:

  • Web page (HTML): We can create HTML web resources to create and embed a custom HTML page in entity forms
  • Stylesheet (CSS):These web resources can be used to create a shared library of stylesheets, which can be used in other web resources
  • Script (Jscript): We can use Script web resources to create reusable code libraries
  • Data (XML): We can use XML web resources to store data in XML format; for example, if we need to store some configuration information, we can use XML web resources and can read them using client-side or server-side code
  • PNG format: We can use this type of web resource to store PNG-format images
  • JPG format: We can use this type of web resource to store JPG-format images
  • GIF format: We can use this type of web resource to store GIF-format images
  • Silverlight (XAP): We can use these web resources to upload Silverlight web resources, and can use them to enhance Microsoft CRM 2011 UI capability
  • Stylesheet (XSL): We can use this type of web resource in XML and HTML web resources to apply XSL stylesheets
  • ICO format: This type of web resource can be used to upload ICO-format images

Web resources can be accessed in different ways. When referring to a web resource using a site map or a ribbon button we can use a $webresource directive. Let's say we have one script web resource with a function OpenWeb and we want to refer that web resource within a ribbon button. We can refer to it using the following code snippet:

<Actions>
<JavaScriptFunctionFunctionName="OpenWeb"Library="$webresource:new_mydemo.js" />
</Actions>

We can also reference web resources using relative and full URLs.

The relative URL is as follows:

<SCRIPT type=text/jscriptsrc="../new_/json2.js"></SCRIPT>

The full URL is as follows:

http://MSCRMSserver/Orrganization/WebResources/new_/json2.js

Tip

When using a full URL in HTML or JavaScript web resources, we should always use context.getServerUrl() to get the correct server URL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.239.182