Home | Microsoft CRM tips and tricks | How to Schedule Workflows in Microsoft CRM Online

How to Schedule Workflows in Microsoft CRM Online

This post is slightly off-topic for the ClickDimensions Marketing blog, but we’ve seen this question come up quite a bit on Microsoft CRM forums and elsewhere: How can I schedule a workflow to run at a specific time every x days? If you have CRM installed on-premise, you can use scheduled Windows tasks on the server, but with CRM Online, you're out of luck. Well, we’ve come up with a simple, creative solution that we think will work for many scenarios. Take a look at the example below.

The scenario: I want to increment a value on the Contact field every Friday at 10:30pm. (This is a very generic scenario for the purposes of illustration. But the example below will work for any type of workflow you want to run at a scheduled time.)

Here’s how we did it:

  1. We created a custom activity entity called “Timed Job Trigger”. We created it as an activity so we could make use of the “Regarding” field, which lets the user associate the record with just about any entity in CRM. In this example, the TEST trigger record is regarding a Contact record, but because it’s an activity entity, it could be regarding any other type of record:
    image
  2. Next, we scheduled a Bulk Delete job that will repeat every Friday night at 10:30 PM. It is designed to delete “Timed Job Trigger” records that match certain criteria (in this case, the Subject = “TEST”, in your scenarios you can create different bulk delete jobs that delete only the Timed Job Trigger records that match other criteria):
    image
  3. Lastly, we created a workflow rule that is executed when a “Timed Job Trigger” record is deleted. This is the trick of this simple solution. In our workflow rule, we perform the action that we want to happen every Friday night at 10:30pm. The timing is governed by the bulk delete job above. (In this example, we are just incrementing a field on the Contact record. You can use this same method to run any workflow logic you want on a schedule.)

    What’s important is that the workflow also creates a new “Timed Job Trigger” record that is regarding the Contact record we want our scheduled job to run against. That way, next Friday, there’s a Timed Job Trigger record associated with the Contact that is available to be deleted and kick off the workflow again.
    image
    image

With some additional creativity, this method can be expanded upon to handle a variety of scenarios. For example, if you want to schedule jobs in bulk, you could create a manual workflow rule that creates a Timed Job Trigger record for Contacts, and apply the workflow against multiple contacts at once. If you think of ways to expand upon this idea, let us know!

About the Author:

Matt Wittemann is an 11-time Microsoft Dynamics CRM MVP and ClickDimensions' Director of Technical Solutions.

One Comment

  1. David January 10, 2013 at 8:36 am - Reply

    This brilliantly wicked

Leave A Comment