This is a collection of sample code for working with Microsoft Dynamics CRM I have used in a variety of blog posts.
C# JavaScript HTML PowerShell Python Batchfile
Clone or download

README.md

This is a collection of sample code for working with Microsoft Dynamics CRM I have used in a variety of blog posts. Many of the samples were originally written for Dynamics CRM 2011, but each solution has been updated to use the Microsoft Dynamics CRM 2013 Service Pack 1 Update Rollup 1 SDK (version 6.1.1 installed from NuGet). I have verified that each solution builds, but I have not necessarily deployed or tested. USE AT YOUR OWN RISK!

###CrmDataSnapshots This solution shows an approach to taking data "snapshots" in Dynamics CRM, similar to Salesforce's analytic snapshots feature. The solution is described in detail in my "A Data Snapshot Framework for Dynamics CRM" blog post.

###CrmJsonProcessing This solution shows an approach to working with JSON-formatted messages in Dynamics CRM custom workflow activities. This code sample was originally described in the MSDN code samples gallery here.

###CrmKeyValueManager This solution shows an approach to working with key-value pair (KVP) data in Dynamics CRM custom workflow activities. This approach was originally discussed in these two blog posts:

###CrmMessageQueuing This is a collection of code for using RabbitMQ as a message broker with Dynamics CRM data interfaces.

  • LucasCrmMessageQueueTools/CliConsumer - This is a sample console application that reads messages from a RabbitMQ queue and writes them to the CLI.
  • LucasCrmMessageQueueTools/CliProvider - This is a sample console application that reads messages from the CLI and publishes them to a RabbitMQ exchange.
  • LucasCrmMessageQueueTools/LeadWriterSample - This a sample console application that reads messages from a RabbitMQ queue and creates corresponding lead records in Dynamics CRM.
  • LucasCrmMessageQueueTools/MessageQueuePlugin - This is a CRM plug-in that publishes notification messages to a RabbitMQ exchange using the RabbitMQ .Net client. This plug-in cannot be executed in the Dynamics CRM sandbox.
  • LucasCrmMessageQueueTools/MessageQueueSandboxPlugin - This is a CRM plug-in that posts notification messages a Node.js application (see the "node-app" item below), which then publishes the messages to a RabbitMQ exchange using the node-amqp library.
  • node-app - This contains the queuewriter.js Node.js application that is used by the MessageQueueSandboxPlugin plug-in. Additionally the leadform.htm web form can be used to submit lead data that will be processed by the LeadWriterSample application.

Here are the relevant blog posts:

###CrmQueueGetNext This solution implements get next case functionality in Dynamics CRM and Unified Service Desk. It is discussed in these two blog posts:

###CrmRegexTools This solution shows how to validate and extract text inside Dynamics CRM custom workflow activities using regular expressions. This approach was originally discussed in these two blog posts:

###CrmScheduledWorkflows This solution shows an method for scheduling recurring workflows in Dynamics CRM. The approach was originally described in my "Scheduling recurring Dynamics CRM workflows with FetchXML" blog post.

###CrmStreamingNotifications This is a proof-of-concept solution for implementing a near real-time streaming API for Dynamics CRM with Node.js and Socket.IO. A video demonstration of the solution in action can be seen here: http://youtu.be/j7rG9qD3ycg.

I also wrote a four-part blog series about this topic.

###CrmTeamConnection This solution shows an approach to managing Dynamics CRM access team membership with connections and custom workflow activities. This approach was originally discussed in my "Managing Microsoft Dynamics CRM 2013 access team membership using connections" blog post.

###CrmUnitTesting This solution contains samples from my "Unit testing custom Microsoft Dynamics CRM code" series series that shows how to test custom CRM code with Moq and Visual Studio's unit testing tools. There are three demo projects and three corresponding Visual Studio unit testing projects:

  • DemoCrm shows the testing approach described in parts 2, 3 and 4 of the series for basic SDK usage.
  • DemoCrmPlugin shows the testing approach for plug-ins described in part 6 of the series.
  • DemoCrmWorkflowActivities shows the testing approach for custom workflow activities described in parts 5, 7 and 8 of the series.

###NodeClientDemo This sample shows how to connect from Node.js to Dynamics CRM using AD FS and OAuth2 for authentication. This blog post has additional information explaining the structure of the solution and the application flow.

###misc-code-samples This directory contains code samples that don't fit anywhere else.