Saturday, 8 October 2016

SharePoint 2013 Workflow: ‘Start a Task Process’ vs. ‘Assign a Task’ and Retrieving Comments from a Task List Item

While working on a SharePoint Designer 2013 (SPD2013) workflow for a document library, I ran into a particular scenario where I needed to get the value from a workflow task list item and include this value in the next assigned task. The specific scenario is noted below:

An approval task gets assigned to ‘Approver A’
If ‘Approver A’ approves, the workflow continues
If ‘Approver A’ rejects, the approver enters a reason for rejection in a ‘Comments’ column.
On rejection, ‘User A’ gets a task to review and complete the task once ready to resubmit for approval.
The requirement: ‘User A’ needs to be able to quickly see why their item (i.e. document) was rejected – ‘User A’ should be able to see the rejection reason as part of their ‘review’ task description.

ActionMultiple AssigneesSingle AssigneeReturns Values
Start a Task ProcessYESYESTask Outcome
Assign a TaskNOYESTask Outcome
Task ID
In SharePoint Designer you can directly access the workflow task list related columns under ‘Association: Task List’ if you have the Task ID of the particular task. Having this option was both fortunate and unfortunate at the time. Fortunate, since it allowed me to quickly accomplish my requirement with an OOTB solution. Unfortunate, because I did not have the Task ID. If you have created SPD2013 workflows, you may have noticed that the ‘Assign a Task’ action returns the Task ID. You also may or may have noticed that in 2013, there is also an action called ‘Start a Task Process.’
ComparisonTaskActions
Let’s take a look at the main differences between these 2 types of actions:
Note: Only differences relevant to the context of this post have been listed.
StartATaskProcess
AssignATask
Note that both of these actions are very similar, and in essence, do the same thing – assign an approval task. The way I see it, if you need to assign the same task to multiple people or to be able to assign a task to each individual person within a group (SharePoint or AD), consider using the ‘Start a Task Process.’ If not, the latter might come in handier if you need the Task ID for anything.
In my case, there was a requirement where I needed to assign the task to multiple people and take the first response as the outcome for the task. In this scenario, the ‘Start a Task Process’ was the right way to go. It was also the cause of the issue, this action did not return the key piece of information I needed, a Task ID. At the time, I turned to finding an alternative solution. I considered more complex routes such as using the ‘Call HTTP Web Service’ to get all tasks related to the current instance of the workflow but such options came with a variety of unnecessary complexities.
As I was concluding that a more complex solution may be unavoidable, between conversations with the client, it was noted that the business process could be tweaked. Turns out that while the particular task could have multiple approvers, 99% of the times it only had 1. Considering this, the client was ok with making it a part of the business process to only allow 1 approver. Luckily for me, tweaking the business process allowed me to use the ‘Assign a Task’ action and put me back in the OOTB business: Use the Task ID to locate the task of interest, get the value needed and save it in a variable. Add the variable to the next task’s description and there you go, requirement met.

AssociationTaskList

1 comment: