Introduction

This code sample builds a Dynamics CRM custom workflow activity that generates summary data snapshots based on a FetchXML query and then stores them as records in the system. This is used to enable functionality similar to Salesforce.com's analytic snapshots. When this custom workflow activity is executed inside a workflow, the custom activity does the following:

  1. Executes a FetchXML query to retrieve aggregate/summary data.
  2. Loops through the results and creates a custom entity record for each result.
  3. The executing workflow then schedules the next snapshot run.

For more information, please look at my A Data Snapshot Framework for Dynamics CRM blog post.

Building the Sample

Visual Studio 2012/.Net 4.5 is required as is the Microsoft Dynamics CRM SDK. No other non-System assemblies are required. Additionally, you must sign the assembly to register it in the CRM sandbox, but I have not included my .snk file in this sample, so you will have to supply your own.

Source Code Files

The sample download contains the TakeSnapshot.cs class required to build the custom workflow activity as part of the overall LucasWorkflowTools solution (this also contains the code used in my "Executing Dynamics CRM workflows based on a FetchXML query" sample) as well as the DataSnapshots CRM unmanaged solution export (DataSnapshots_1_0_0_0.zip). The solution export archive contains an already built assembly with the custom workflow activity ready for registration in your CRM system.