Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > SharePoint 2010 Workflow: Task due in hours, not days
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
December 28
SharePoint 2010 Workflow: Task due in hours, not days

In SharePoint 2010 workflow (the enterprise version), there is a great new task process designer in workflows.  It basically lets you create a workflow inside of a workflow.  One thing that I came across this week was a task that needed to be assigned to someone, but the due date for the task was in just a couple of hours.  The action that I use in the workflow is called “Start Feedback Process” (this also works with the Approval process one).  The interface does not have a drop-down for hours.  As you can see below, it has Days, Weeks and Months.

ch5[58]

So, I’ve figured out how to set the “due date for task process” to X hours after the workflow is kicked off.  In my case, I don’t have multiple tasks being assigned in the one task process, therefore I can just set a single “Due Date for Task Process”.  Here’s how.

In this example, I want the task to be due 3 hours after it has been assigned:

  1. Create a SharePoint Designer 2010 workflow.  Add the action called “Add Time to Date”.
    ch5[59]
  2. Click on the zero, and change it to 3.
  3. Click on the “minutes” and change it to “hours”.
  4. Click on the word date, click the function button and choose:
    ch5[60]
    This new data source called Workflow Context is new in 2010.  Basically we’re adding 3 hours to whenever the workflow started.
  5. Click on the name of the variable, and “create a new variable” and call it NextDueTime.
  6. This is the final result of what this first action looks like:
    ch5[61]
  7. Add the action, either “Start Feedback Process” or “Start Approval Process”.  Again, if you don’t see these, it means you don’t have the enterprise version of SharePoint 2010.
    ch5[62]
  8. Click the blue text these users.
  9. Add at least one person as a participant and a title.  Click the function button next to the Due Date for Task Process.
  10. The data source is Workflow variables and parameters, and pick the name of the variable you created earlier, NextDueTime.  This is what the task screen should look like.  Click OK.
    ch5[63]
  11. Publish your workflow and try it out.

What if your workflow is a pretty long workflow, and you don’t necessarily need the hours to be calculated from the time that the workflow starts, because the workflow could be running for days before it arrives at this particular task. 

Bonus Points

Create a separate list on the site, I just call it “Change History”.  In the workflow, immediately before the step where you add the hours (step 1 above), you add an action to “create list item” in that other change history list.  Simply make up a title like “first task being assigned”.  You’ll need the variable in this action, so make a note of it.  I’ll refer to it as “Task1History”. 

Add an action to pause for 1 minute.

Add an action to add time to date.  Instead of what we did at step 4 with the workflow context, set it to this instead:
ch5[64]

You’re pulling the created date/time from the Change history item that you created, and matching it with the item ID from the action where you created the new item in the change history list.  I added the pause because it appears as though the workflow moves so fast that the item hasn’t been created by the time it moves to the next action.

Again, this second “bonus” part may not be necessary for you.  I have found that there is no action in the workflow that will grab the current date/time “right now” at any point in a workflow.  There’s the workflow context of “date/time last run”, but that’s not “now”, it’s the last time the workflow ran.  So, this method of creating an item in another list was just something I came up with to accomplish “now”.  Please let me know if there’s a better way… I just couldn’t figure it out.  Winking smile

 

 

 

Comments

Manasvi

Laura - Thanks for figuring this out so quickly! :) I am sure others will find this tip useful as well!!
Shane YoungNo presence information on 12/29/2010 11:56 AM

Arsalan Adam Khatri

How do we achieve this in MOSS 2007?  I am stuck in a mess here...
Shane YoungNo presence information on 7/12/2011 6:04 AM

Jason Ramsey

For a single approval task that's assigned to a group of users (in serial), is there any way to set different task due times for each user in that group? In other words, first user in the sequence gets 5 hours, second gets 4 hours, third gets 3 hours, etc...
Shane YoungNo presence information on 12/19/2011 12:29 PM

Laura

Jason, When I've done exactly what you're asking, I ended up having to create each task as a whole separate task process, not in the same one, unfortunately.  I haven't been able to figure out if there's a way to change any fields such as due date within a single process, to make it different among tasks.
Laura RogersNo presence information on 12/19/2011 4:08 PM

Diaz

It works to me.. Thanks a lot :D
 on 1/24/2012 11:48 PM
​I have disabled any new comments on this, because my blog has moved to a new site.  Please go here: http://www.wonderlaura.com
RSS FeedFacebookYouTube
 

 Our Books for End Users