Site icon @WonderLaura

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.


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”.
  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:

    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:
  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.
  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.
  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:

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. 

Exit mobile version