Browse DevX
Sign up for e-mail newsletters from DevX


Capitalizing on Microsoft Dynamics CRM 3.0 Callouts: Introduction to Callouts : Page 2

Add value to your CRM system by firing customized actions in response to CRM events.

Implementing a Callout
As an example, here's a sample callout that appends sales leads to a text file whenever the lead status changes from "new" to a different status. Here, you'd use the PostUpdate event of the lead entity to trigger the callout. To begin, you need to create a callout configuration file (if you don't have one already). To do that:

  1. Restart IIS
  2. Navigate to C:\ Program Files\Microsoft CRM\server\bin\assembly

  3. Author's Note: All paths assume MSCRM is installed on your C:\ drive.

  4. In that folder, create a new XML file named callout.config.xml.
  5. Open this file in notepad and paste the contents of the sample file callout.config.xml (available in the downloadable code that accompanies this article).
  6. Restart IIS again.
Now, you need to create the callout assembly. To do so, follow these ten steps.

  1. Open Visual Studio and create a new class library named LeadIntegrationCRMCallout.
  2. Copy the Microsoft.Crm.Platform.Callout.Base.dll located in the Microsoft CRM server CD (Disk 1) at <server CD>\GAC to your local bin folder.
  3. Add a reference to that DLL.
  4. Add a web service reference to the CRM service and name it CrmSdk.
  5. Rename the default class1.cs to LeadCallout.cs.
  6. Paste (or download) the code shown below into LeadCallout.cs
       public override void PostUpdate(
          CalloutUserContext userContext, 
          CalloutEntityContext entityContext, 
          string preImageEntityXml, 
          string postImageEntityXml)
          XmlDocument entityDoc;
             entityDoc = new XmlDocument();
             string nameSpaceValue = entityDoc.ChildNodes[0].Attributes
             XmlNamespaceManager xsn = new
             xsn.AddNamespace("z," nameSpaceValue);
             string entityXpath = "//z:BusinessEntity";
             XmlNode businessEntityNode = 
                entityDoc.SelectSingleNode(entityXpath, xsn);
             string businessEntityName = 
             switch (businessEntityName.Trim().ToLower().ToString())
                case MSCRMLEAD:
                   ProcessLeads(preImageEntityXml, postImageEntityXml);
          catch (Exception ex)
             //TODO :Log exceptions to Event log
             entityDoc = null;
    To finish the procedure:

  8. Build the assembly.
  9. Restart IIS.
  10. Copy the newly created assembly into the C:\Program Files\Microsoft CRM\server\bin\assembly folder.
  11. Restart IIS.

Thanks for your registration, follow us on our social networks to keep up-to-date