·
3 min read

Use Workflow to Configure Business Data Auditing in Microsoft Dynamics CRM 4.0

Microsoft Dynamics CRM 4.0 has delivered a powerful workflow platform built on Windows Workflow Foundation. This workflow platform is highly configurable and means many processes can be built without the need to write a single line of code.

Auditing is a common requirement with business applications including CRM. This article will talk you through the basics of creating comprehensive auditing for your Microsoft Dynamics CRM 4.0 deployment. This example allows you to record changes to any field in your solution on any record. If you have simpler auditing requirements then consider just creating a work note on specific events within your CRM system. Either way, Microsoft Dynamics CRM 4.0 workflow is perfect for this requirement and easy to configure!

Essentially how this solution works is as follows:

– For each CRM entity we want to perform auditing on, we will create a linked custom entity to hold a snapshot of the record at the time a change is made to the CRM record. For example, if we wanted to conduct auditing on Contacts we would create an entity called Contact Audit. This entity will have all of the attributes of the Contact entity that we want to track via auditing.

  • We then design the form of our audit entity so that it has all the fields we want to set during an audit action and publish this form.
  • We will also edit the Associated view that shows in one line all of the attributes being audited.
  • We then build a workflow which runs on create as well as update of the specific attributes we are interested in auditing. This workflow will create a new audit record and set the attribute values to be the newly created or updated attributes from our parent record.
  • As each record is created or updated we get a snapshot of the record at that time and through the view we can see the full history of changes made to this record.
  • You could then build your own reports to print out audit logs and/or secure the audit records to prevent them from being updated or deleted.

We will work through these steps using a specific example to create an audit system for Contact records in Dynamics CRM. You can then use this technique for any record types that you want to audit.

Step 1: Create the custom audit entity as follows:

clip_image002

Step 2: Create the attributes of the Contact Audit entity.

clip_image004

Add as many attributes as you like but only add the attributes you want to create an audit copy of. If you don’t use yomifirstname then don’t create this attribute in your Contact Audit entity.

Step 3: Create an N:1 relationship between Contact and Contact Audit.

clip_image006

Set the relationship behavior setting to Referential, Restrict Delete so that if the record is deleted then the audit records won’t be.

Step 4: Design the form of the Contact Audit entity, ensure that all audit attributes appear on this form.

clip_image008

Step 5: Configure the Associated View of this Contact Audit entity to display all attributes you are interested in viewing in a list grid.

clip_image010

Step 6: Publish your schema changes.

clip_image012

Step 7: Set security on the Contact Audit entity in your security roles.

clip_image014

Step 8: Create a new workflow called Contact Business Data Auditing.

clip_image016

Ensure that you click the Record is created and the Record attributes change start events.

Step 9: Click the Select button next to the Record attributes change checkbox and tick every attribute that you want to track changes on.

clip_image018

Remember you don’t have to select every attribute, only the ones that you’re interested in auditing and you can always change your mind later and either include or exclude attributes from auditing.

Step 10: Add a create record step into the workflow. Select Contact Audit from the Create drop down list and then click the Set Properties button.

clip_image020

Step 11: Add a check condition step to the workflow. We will determine if this is a create or update transaction.

clip_image022

If the Created On date equals the Modified On date then this is a create transaction. If they are different then this must be an update. Click Save and Close.

Step 12: If this is a create transaction then we will add an Update Record workflow step and update the Name attribute to reflect that it is a create transaction.

clip_image024

Step 13: Add an Otherwise clause to handle the update transactions. We will add an Update Record workflow step and update the Name attribute to reflect that it is an update transaction.

clip_image026

Publish your workflow and you have enabled business data auditing on Contacts – repeat the entire process for any other entities that you want to conduct auditing on!

Other things you could do to enrich your auditing solution:

  • Create SQL Server Reporting services reports that display audit logs.
  • Add other events to your workflow which audit actions such as assign or delete.

As you can see Microsoft Dynamics CRM 4.0 workflow is very powerful! You can achieve a lot of things without needing .NET development skills. Hopefully this has given you insight into some of the great things you can achieve through workflow configuration!

Best wishes,

Reuben Krippner