Secondary Workflow Example in SharePoint Designer
I recently built a prototype to show how SharePoint and SharePoint Designer workflows can be used to automate an HR performance review process. I had to use a secondary workflow as described in SharePoint Designer: Create a secondary workflow, but had to come up with a different solution for how to set due dates. Following is an explanation of why I needed the secondary workflow for this example and how I got the due dates to work.
The basic requirements are:
- A manager wants to start a performance review process for an employee.
- Each employee has some list of people to review them.
- The review consists of filling out an InfoPath form.
I created the following in SharePoint:
|Performance Reviews||An InfoPath form library that will contain completed review forms. This form library contains the performance review form as an InfoPath form template.|
|Reviewer Tasks||A task list to store tasks assigned to reviewers.|
|Reviewers||A custom list of reviewers for each person being reviewed. This list has two columns: Employee and Reviewers. The latter is a multiple select Person column.|
Now the workflows. A workflow needs a list or library item to be started. Since the Performance Reviews form library only contains completed review forms, it is not a candidate for the workflow. Instead, my Reviewers list contains the mapping between employees and reviewers and is where the workflow will start. Following the diagramming used in the referenced article, here are my lists and workflows:
- A manager manually starts the Performance Review workflow for a particular employee. This workflow uses an initiation variable to get the Due Date for the performance review from the manager.
- The Performance Review workflow creates tasks for each of the reviewers.
- The Set Task Details workflow runs automatically on each of the new tasks to set their details and send email notifications to the reviewers.
The Performance Review workflow uses the Assign a To-Do Item action to assign tasks to the reviewers.The Set Task Details workflow is required because the Assign a To-Do Item action has the following limitations in this case:
- It only supports a static title and description. I need both the title and the description to include lookup fields so the assigned tasks are most meaningful to the reviewers (e.g. “Please complete a performance review for Ben Hickman”).
- It doesn’t support a due date. I want to set a due date on the tasks.
- It does not send email notifications that a task has been assigned. I could setup Alerts on the task list, but I want control over the format and details of the email notifications.
Now the trick is: how does the Secondary Workflow find the Employee name and the Due Date? As described in the article referenced above, the Secondary Workflow can use the Current Item – Workflow Item ID to reference the Reviewers item id that caused the task to be created. I can then use that Workflow Item ID to lookup the associated item in the Reviewers list and lookup the Employee name, like this:
Now, how about the Due Date? Since I gathered that as an initiation variable in the Primary Workflow, it’s not immediately available to the Secondary Workflow. So, I better make it available. I do that by having the Primary Workflow store it in the Current Due Date column in the Reviewers list. Then, the Secondary workflow can look it up just like Employee like this: