Use a Custom Audit Entity and a Simple Workflow to Find Out
I’ve always liked lists: shopping lists, birthday gift lists, to-do lists, top ten American League hitters by different categories, you name it. One of my current favorite list types is the Dynamics CRM Marketing List. (I’m sure you wondered where I was going with that list thing!).
It took me a while to appreciate the value of marketing lists and to develop some good intuition about their strengths (and their limitations!). In this article I’ll provide some tips and tricks on how to get the most out of marketing lists, and show you how to use a custom entity and an audit workflow to keep track of how your lists change over time.
Marketing List Fact #1
Marketing lists have “members”, and those members are restricted to Account, Contact, and Lead records only. This is one of the primary limitations of marketing lists. From a practical standpoint, it means that if you want to take advantage of marketing lists you might have to “shoehorn” something that you might not regularly think of as one of these entities…into one of these entities.
Now unless you know the trick I’ll describe later, it might never occur to you to do this, but you can decide for yourself later on.
Marketing List Fact #2
Marketing lists are static. The way they work is, you build a query to select the list’s members from the underlying records in your account, contact or lead tables. After you add the members to your list you get a convenient “members count” value that tells you how many members there are. This is nice, by the way, since it’s not that easy to tell how many records you have. (Navigate to the standard contacts grid, and see if you can tell how many contacts you have. If you’ve got more than 250, there’s nothing built in to the standard UI to tell you!)
But the point is, once you add members to a marketing list, no matter what happens to the underlying data, the members count stays the same until you manually update it. For example, on a monthly basis I send out an email newsletter, and I use a marketing list of Contact records for the purpose. Every month before sending out the newsletter, I need to update the members of the marketing list to make sure I do things like this:
- Add new contacts who want to receive the email
- Delete contacts who may have opted out, or may no longer be active
Once you get used to the fact that marketing lists are static you appreciate why they’re that way…but first you need to realize it and make refreshing them part of your regular routine.
Marketing List Fact #3
As I mentioned previously, marketing lists have a “members count” field that tells you how many current members are in the list. If you’re interested in building your marketing lists over time, this is obviously an important number, and if you’re a marketing manager who is partly compensated by growing marketing lists, it’s a really important number. As you may know, there are no built-in audit capabilities for any Dynamics CRM records. There are some well-known techniques you can use to add auditing for records like accounts, opportunities, and so forth; here’s a link to an article I wrote on the topic.
What I’ll describe here is a way you can adapt that technique to the current challenge: how do you keep track of how your marketing lists change (hopefully, grow!) over time.
Once you understand the general approach to creating audit records, this version is simple:
1. Create a custom entity (I call mine “Marketing List Audit”) with a custom integer attribute called something like “Members Count”.
2. Create a 1:N relationship from Marketing List to the Marketing List Audit entity.
3. Create a workflow on the Marketing List entity that adds a related record to the Marketing List Audit entity. Update the audit record’s “Members Count” attribute with the current value of “Members Count” from the Marketing List.
That’s the basic technique. Here are a couple examples of how it can look when you’ve got this kind of auditing in place.
Here’s the view from the Marketing List, of all the associated audit records, the count and the date the audit record was created:

Here’s a part of a report, written using the CRM 4.0 Report Wizard – this is a good example of how a time series of data can look. You can see that the data points map to the audit records shown in the previous screen shot.

Implementing the Marketing List Audit Functionality
Just for fun, I’ll explain this functionality using screenshots of the workflow itself, starting off with one of the Administration tab. Consider using the description field to make your workflows more self-documenting, like I show here:

The workflow is written against the Marketing List entity, and you can see in this example I expose it for On Demand use, and have it run automatically when attributes (members count) change:
It only does one thing: creates a new record for the Marketing List Audit entity. I use Dynamic Values to populate the name, relate it to the parent record, and fill in the value of the Member Count field:

That’s pretty much it!
One little security caveat
One thing to keep in mind: if you make a workflow like this available for On Demand use, another user might be able to run it. If they do, they need to have Write privilege on the Marketing List Audit entity. This is a common gotcha in these situations, since if you have it run automatically that is not the case. This can be a confusing issue, so here’s a quick summary:
- Workflows run On Demand run in the security context of the User who ran the workflow.
- Workflows run automatically run in the security context of the Owner of the workflow.
Since it tends to be System Administrator types who create automatic workflows, those workflows generally won’t have any problems running. In this example, since System Administrators have Write privilege on all entities (including custom ones), it will work. But if it’s exposed On Demand and the User running it doesn’t have Write privilege on the custom entity, it will fail with an ugly error message.
Let me know if you have any questions, and I hope you find this useful! If you do, check out the brand new Second Edition of my workflows book, cleverly titled Building Dynamics CRM 4.0 Workflows, Second Edition. It’s got 150 pages of workflows like this one, and lots of others. If you purchase it, you also get a subscription to the online version of the book, where you can download all of the workflows from the book, plus more as I add them.