Workflow Best Practices – Reduce Wait time

by Bill Owens 29. May 2010 00:56

As many of you know, the more items you have in a wait state in MSCRM the slower the system can perform. On of the best practices is to wake up every so often and perform your check and go back to sleep if the condition doesn’t meet.

 

Example:

Case: Wait 7 days and if the Status is not Completed then Send an escalation Email.

Best Practice would have workflow do some thing like this. (This is pseudo code)

Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Wait 1 day
If Status = Close then Stop Workflow
Send Escalation Email

Well, what if you wanted to change the durations from 7 days to 3. Worse yet, this is a 30 day wait process with 30 of those wonderful lines. The answer is that you can change the workflow, but all of the currently running workflows will still have the old code instantiated and they need to work through.

I came up with another method, some of you may have done the same, to make this more manageable.

 

I added to the case 3 fields.

  • Escalation – Next Wake up
    • This is a date and time for the workflow to next wake up
  • Escalation – Wakeup Count
    • This is an integer that tells you how many times the workflow has waited
  • Escalation – Escalation On
    • This is an integer that when the Escalation – Wakeup count is equal to or greater than it escalates

image

Putting it together in a workflow

Create a workflow for cases

eee

Change the Scope to Organization and check off the As a Child Workflow

Startwf

Add a check condition step to check the case Escalation – Next Check is blank.

checkwfes

Add under the if statement un update to the case Escalation – Next Check to be create on date time and set the Escalation – Wakeup Count to 1 plus the Escalation – Escalate On to 7 (1 week)

 

wf2

 wf33

Now on a new line add the Add 1 day to the Escalation – Next Check

wf4

wf3

Add the Wait till Escalation Next Step

wf5

wf6

Now do your check to see if the condition is right to quit this workflow. In this case if the case is not active then we do not need to escalate. Stop the workflow if it is true.

wf8

Now add the escalation logic. If Escalation - Wakeup Count is => Escalation - Escalate on then send escalation and stop

wf9

Add 1 to the Escalation - Wakeup Count. Add un update to the case

wf12

image

It should look like this

wf10

Now add the last step and that is to call this workflow . NOTE. You will need to save the workflow before you can call it.

wf14

 

Publish and now try it. You will find that it is easier to update the Escalation process even on items currently running. Plus you have an easy way to force many workflows to stop within a day if needed. Enjoy and I hope this helps.

 

Bill Owens

Tags: ,

CRM 4.0

Page List

About the author

I work for a consulting firm in Dublin Ohio called Affiliated Resource Group. For the last five years I have been spearheading our Microsoft Dynamics CRM practice. I have a deep appreciation for the Microsoft CRM platform and I am very excited about it. You might even describe me as a Microsoft CRM Advocate. I have many battle scars from my experience with the product and I’m constantly being asked questions about CRM and how-to-do something in it. Hence, this BLOG is to help disseminate that knowledge and information to everyone. As of last year I was posting links to many other blogs to help spread the knowledge, but now with the community.dynamics.com doing that for me, I will be following that practice unless a really juicy article catches my eye. Many people have asked where my post are for the first half of 2010, my company had me posting to another blog and maintain two was near impossible. I am now down to just this blog. So good luck and I hope that this blog may help in some way. If you have suggestions or questions, please email me them.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 BillOnCRM