James Downey’s CRM Blog
Thoughts on the technology and business of CRM

Add by Business Days Workflow Activity

Sunday, 14 December 2008 17:31 by James Downey

Out of the box, Dynamics CRM workflows give users the ability to add and subtract days in order to dynamically populate attribute values. If you wanted to set a task due in two days, you could use the dynamic value editor below and click Add. Simple enough but what if you wanted to set the task due within two business days. Unfortunately, the out-of-the-box CRM workflow tool does not provide this functionality. When it adds by days it does not skip weekends and holidays.


 
Because I don’t care to work on holidays and weekends, I’ve created custom workflow activities that can add and subtract business days. After compiling the code and registering the assembly and activities with CRM, just add a step to a workflow and under Date Utilities select Add Business Days.


 
Enter the starting date for the calculation and the number of business days to add.


 
Make sure to give the step a meaningful name such as Calculate Due Date. 


 
You can then use this date to populate a date field in a following workflow step. For example, add a Create Record step and select Task. With the Due field selected, select the Calculate Due Date step and then select the Output Date from the drop down list below. 


 
And that’s it. Now just publish the workflow and try it out.

In order to add the date utilities to the CRM workflow tool, download the assembly and register it with CRM. Learn how to register a plugin on MSDN and then download the plugin registration tool.

Download Assembly

Download Code

(Code is a free download with no warranty and no support. If you send me a question by email, I’ll try to answer when I find time.)

If you prefer to compile the code yourself, create a Workflow Activity Library project in Visual Studio, add the three code files in the download, and add references to the Microsoft.crm.sdk.dll and Microsoft.crm.sdktypeproxy.dll.

I’m a big fan of custom workflow activities for Dynamics CRM. It is the ultimate in code reuse. Just write a custom activity and register it with CRM and then power users can use it as a building block to create powerful workflows.

 

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5