<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>CRM 2011 HTML Web Resource </title>
<!-- including the 'ClientGlobalContext.js.asp'
-- which gives the context information-->
<script src="ClientGlobalContext.js.aspx">
</script>
<!-- including the minified version of jquery-->
<script type="text/javascript" src="new_jquery_1.4.1.min.js"></script>
<script language="javascript">
function getAllData() {
var serverUrl;
var ODataPath;
var userid;
var userRole;
var OrgName;
var context = GetGlobalContext();
serverUrl = context.getServerUrl();
ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
userid = context.getUserId();
userRole = context.getUserRoles();
OrgName = context.getOrgUniqueName();
Text1.Title = serverUrl;
Text2.Title = userid;
Text3.Title = userRole;
Text4.Title = OrgName;
Text1.value = serverUrl;
Text2.value = userid;
Text3.value = userRole;
Text4.value = OrgName;
}
</script>
</head>
<body onload="getAllData();">
<p>ServerURL:
<input id="Text1" type="text" /></p>
<p>User ID
<input id="Text2" type="text" /></p>
<p>User Role
<input id="Text3" type="text" /></p>
<p>Oraganization
<input id="Text4" type="text" /></p>
</body>
</html>
In this post we will see
- how to add HTML web resource to CRM 2011 Form
- How to get the Context in the HTML web resource
- How to use the GetGlobalContext function,
Steps to Follow
- Create a new solution
- Add a new Entity called –’TestforHTMLWebresource’
- Add a Web Resource with the name’Jquery1.4.1’ minified version as shown in the screenshot
-
- Add another HTML page as a webresource but with the following Code.
- Save and Publish the HTML webresource,
- open the Entity form
- insert the above created HTML web resource
- Publish all the customizations and Export the Solution
- Reimport the solution
- Refresh the browser.
- You can observe the HTML Webresource showing the Following Values
- server Url
- userId
- User Role
- Organization.
- The solution appears as detailed in the below screenshot
-
- The complete solution file can be downloaded from here