Microsoft Dynamics CRM is a powerful program, and what sets it apart from the many other choices in the CRM application space is its tight integration to the Microsoft platform. When Vista shipped, I immediately started looking for new and exciting ways to demonstrate the value of Microsoft CRM and the Microsoft platform, and the first interesting area I discovered is gadgets. Being a true propeller head, my favorite gadget is the CPU utilization meter, and I also love the pictures slideshow gadget. I decided to create a gadget that can display the accounts and contacts from Microsoft Dynamics CRM on the user desktop.
Note that this article assumes familiarity with developing gadgets for Windows Vista. If you're new to gadgets, I suggest first reading the article: http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx
About CRM and the gadget
While a properly implemented CRM system can be a very powerful tool, a complaint heard often is that there is so much information in the system, it is impossible to make any sense of it. The tools provided with Microsoft CRM can be designed so that the users can quickly access the important information stored in the system, and the MSCRM gadget is designed to make this process even faster.
The gadget displays the list of accounts and contacts associated with the currently logged on user (made possible by MSCRM's integration with Active Directory) and then if the user clicks an item in the list, the MSCRM record will load in a browser window.
Please note that in order to use this gadget, you must have access to a functioning MSCRM installation, and you must know the URL of your MSCRM server.
Using the code
bChecked=(document.tabcontrol && document.tabcontrol.tabcheck.checked)? true : false
if (document.getElementById && !bChecked)
for (i=0; i<theTablinks.length; i++)
Microsoft Dynamics CRM provides a very powerful web services API which provides access to the underlying system. So the basic idea behind this gadget was to instantiate a Microsoft.XMLHTTP ActiveX object, and then use that object to call into the MSCRM web services to retrieve the account and contact information. The challenge is that the call is not as simple as a SQL query like
"select * from Accounts". We need to build an actual SOAP message. In order to do this I cheated a bit and enabled logging on my MSCRM server, made a call to the web services to retrieve the accounts and contacts, and then parsed the resulting log file to find the call I needed. For those interested, the log file is included with the downloadable source files for this project.
I then built the message thus:
var serverUrl = "http://danubecrm:5555/mscrmservices/2006";
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", serverUrl + "/crmservice.asmx", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8")
xmlhttp.send("<?xml version='1.0' encoding='utf-8'?>"+"\n\n"+"<soap:Envelope"+
' <soap:Body>' +
' <query xmlns:q1=http://schemas.microsoft.com/crm/2006/Query
' xsi:type="q1:QueryExpression" xmlns="http://schemas.microsoft.com/crm/2006/WebServices">'+
' <q1:EntityName>account</q1:EntityName>' +
' <q1:ColumnSet xsi:type="q1:ColumnSet">' +
' <q1:Attributes>' +
' <q1:Attribute>accountid</q1:Attribute>' +
' <q1:Attribute>name</q1:Attribute>' +
' </q1:Attributes>' +
' </q1:ColumnSet>' +
' <q1:Distinct>false</q1:Distinct>' +
The next step is to parse the XML returned by the CRM web services call and separate the returned entities. The code below also prints out the returned entities inside HTML anchors so they are clickable.
var result = xmlhttp.responseXML.xml;
var BEs= result.split("<BusinessEntities>");
var BE = BEs.split("<BusinessEntity");
for (i = 0; i < BE.length; i++)
firstname = BE[i].indexOf("<name>")+6;
secondname = BE[i].indexOf("</name>");
firstid = BE[i].indexOf("<accountid>")+11;
secondid = BE[i].indexOf("</accountid>");
if (BE[i].substring(firstid,secondid).length > 0 )
document.writeln("<a href=\"http://danubecrm:5555/sfa/accts/edit.aspx?id=" +
BE[i].substring(firstid,secondid) + "\" target=\"new\"><font size=\"2px\"" +
"name=\"verdana\">" + BE[i].substring(firstname,secondname) + "</font></a><BR>");
AccessCrmWebServices() but of course the name does not matter.
And that's pretty much it! Now we just deploy the gadget files to the Vista machine as described in the overview article referenced in the beginning of this article, and the gadget will be available.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.