Dynamics CRM 2011 · Javascript · Web Resource

CRM 2011: Referencing Web Resources (Relative Url/Path)

This is a great functionality of CRM 2011. CRM will simulate directories so that you can add references to other web resources using relative url.

Say you are writing a html web resource that uses libraries, custom javascript files and stylesheets.
mypage.html
jquery.js
myscript.js
mystyle.css

<html>
<head>
  <link rel="stylesheet" type="text/css" href="styles/mystyle.css" /> 
  <script type="text/javascript" src="scripts/jquery.js"></script>  
  <script type="text/javascript" src="scripts/myscript.js"></script>  
</head>
<body>
...
</body>

What you need to do is to add the webresource with unique name following the format below:
jquery.js: prefix_/scripts/jquery.js
myscript.js: prefix_/scripts/myscript.js
mystyle.css: prefix_/styles/mystyle.css

Say you have a bit of OCD like me and like things to appear in a group in solution web resource list and like your page to be in a ‘directory’ as well.
mypage.html: prefix_/pages/mypage.html

Add reference to your scripts and stylesheet:

<html>
<head>
  <link rel="stylesheet" type="text/css" href="../styles/mystyle.css" /> 
  <script type="text/javascript" src="../scripts/jquery.js"></script>  
  <script type="text/javascript" src="../scripts/myscript.js"></script>  
</head>
<body>
...
</body>

Cheers – Sy

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s