Monthly Archives: October 2012

Step By Step Adding Configuration Page in Solution MS CRM 2011 Part -2

In my earlier post I have used a simple html web resource to set as configuration page and I found this post quite popular, so I thought to write another post on this. In this post I will show how can we get configuration details from xml web resource to display it in configuration page. We can use it in different way, but for the demo purpose I have kept it simple. You can follow below steps to show configuration data stored in xml web resource:

1. Create a xml web resource where we can store our configuration information, for example our product registration information. I am using below xml in my  new_Configuration.xml web resource

<?xml version=”1.0″ encoding=”utf-8″?>
<Configuration>
  <RegisteredTo>Mahender Pal</RegisteredTo>
  <RegisterationID>108837729827822</RegisterationID>
  <Description>This is a xRM Demo solution</Description>
</Configuration>

2. Create a new html web resource and add below code to read data from our xml web resource

<HTML xmlns=”http://www.w3.org/1999/xhtml”><HEAD><TITLE>xRM Demo</TITLE>
<SCRIPT type=text/javascript>
function ShowConfiguration() {
var Webresourceurl = WebResourceURL; //we need to provide our xml webresource url here we can get it from CRM
var nodePath = “//Configuration”;
var XmlDoc= new ActiveXObject(“Microsoft.XMLDOM”);
XmlDoc.preserveWhiteSpace = true;
XmlDoc.async = false;
XmlDoc.load(Webresourceurl);
var nodelist;
nodelist = doc.selectNodes(nodePath);
document.getElementById(‘registeredto’).value = nodelist[0].selectSingleNode(“RegisteredTo”).nodeTypedValue;
document.getElementById(‘registerationid’).value = nodelist[0].selectSingleNode(“RegisterationID”).nodeTypedValue;
document.getElementById(‘description’).value =  nodelist[0].selectSingleNode(“Description”).nodeTypedValue;
}
</SCRIPT>

<META charset=utf-8></HEAD>
<BODY onload=ShowConfiguration() contentEditable=true bgColor=#6666ff>
<P><FONT size=6 face=”Tahoma, Verdana, Arial”><FONT color=#ffffff><STRONG>Product Registertion Information</STRONG></FONT>&nbsp;</FONT></P>
<HR>

<TABLE>
<TBODY>
<TR>
<TD><STRONG><FONT color=#ffffff>Product Registered To :</FONT></STRONG></TD>
<TD><INPUT style=”BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BACKGROUND-COLOR: #6666ff; COLOR: #ffffff; FONT-SIZE: 12px; BORDER-TOP: medium none; FONT-WEIGHT: bold; BORDER-RIGHT: medium none” id=registeredto TD <></TD>
<TR>
<TD><STRONG><FONT color=#ffffff>Registration ID :</FONT></STRONG></TD>
<TD><INPUT style=”BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BACKGROUND-COLOR: #6666ff; COLOR: #ffffff; FONT-SIZE: 12px; BORDER-TOP: medium none; FONT-WEIGHT: bold; BORDER-RIGHT: medium none” id=registerationid TD <></TD>
<TR>
<TD><STRONG><FONT color=#ffffff>Product Description :</FONT></STRONG></TD>
<TD><INPUT style=”BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BACKGROUND-COLOR: #6666ff; COLOR: #ffffff; FONT-SIZE: 12px; BORDER-TOP: medium none; FONT-WEIGHT: bold; BORDER-RIGHT: medium none” id=description size=40 TD <></TD></TR></TBODY></TABLE></BODY></HTML>

3. Set your html web resource in configuration page lookup in solution and save it.

Now when you will try to click configuration page you should get it like below

2 Comments

Filed under MS CRM 2011

Retrieve MS CRM fields using late bound

In my earlier post I have provided sample code to set different data type fields using late bound in MS CRM 2011. In this post I am going to how can we fetch value from different data type fields.

Entity _Account = service.Retrieve(“account”, new Guid(“XXXXX”), new ColumnSet(new string[] { “name”, “accountcategorycode”, “new_collectiondate”, “creditlimit”, “parentaccountid”, “new_executivecommission”, “new_isbilled” }));

//To fetch string value
string Name = _Account[“name”].ToString();

//To fetch optionset selected value
int OptionSetValue = ((OptionSetValue)_Account[“accountcategorycode”]).Value;

//To fetch date time field value
DateTime CollectionDate = ((DateTime)_Account[“new_collectiondate”]).Date;

//To fetch money field value
decimal Creditlimit = ((Money)_Account[“creditlimit”]).Value;

//To fetch decimal field value
decimal Executivecommission = (decimal)_Account[“new_executivecommission”];

//To fetch lockup field
Guid ParentAccountID = ((EntityReference)_Account[“parentaccountid”]).Id;

//To fetch Boolean field

Boolean IsBilled=(Boolean)_Account[“new_isbilled”];


Enjoy !!!

1 Comment

Filed under MS CRM 2011

MVP Renewed

Third year in a row I have been awarded Microsoft MVP for Microsoft Dynamics CRM.

Thanks to Microsoft, Dynamics CRM community members and my mvp lead Tanmay Kapoor.

Special thanks for my family member and my friends for their continuous support.

7 Comments

Filed under MVP