A fundamental condition that I always encountered when gathering workflow requirement is to get the user’s manager approval, a tedious amount of coding to connect to active directory retrieve user profile information, get his manager login name, pass it as a parameter to the workflow, create a custom task for the manager with a notification.
SharePoint 2010 Designer to the rescue, you can do all the above in 15 clicks, with ZERO code involved. Just by doing the following:
- Open SharePoint Designer 2010 and connect to your SharePoint site.
- Click Workflows and select the workflow type you need, for this presentation I’ll use reusable workflow with All content types as my scope. But this doesn’t affect the following logic, the same steps applies for the List and Site workflows.
- From the Workflow ribbon select Actions > Collect Data from User, you can also select assign a to-do task but collect action from user allows you to create a custom task for the manager
- This will show you the Action in the workflow editor.
- The action is constructed from three parts:
- The data, which is the custom task that will be collected
- This user, which in our case the manager
- Output to variable: collect. Collect is the task ID which you can change it, use it to refer to the task when you need to pass a variable through this task.
- Clicking on data will allow you to create the custom task by starting the task wizard, open the wizard and click Next.
- You will need to specify a Task name, and you can also specify a description. For now lets call the task “Review Task”. And click Next
- Now you can Specify the Task custom field by clicking Add and select the field type, I will specify two field:
- Approved as a choice with Yes/No.
- Comment as a text area.
9. Provide the choices values, and hit Finish
- Now it should be looking like this, with both fields listed
- After finishing creating the Task, the condition will change in the editor to reflect the task name.
- Now to the Fun part, getting the user manager. Simply click this user, Select “Workflow lookup for a user…”, and click Add
- Now you need to specify data source, in other situation you will need to specify the active directory, create a connection and the rest of this headache. All you need to do now is to select “User Profile” from the end of the list.
- This will display all the user profile attribute that you can select from, such as manager. Select “Manager” and specify the out as “login name”. This will lookup for the user manager and return his login name as a parapater in order to assign the task for this user’s manager
- Find the list item section allows you to select the user which you need his manager approval. In our case we the manager for the user who started the workflow. So I will select the Field as “Account Name” and click on the formula button in the value field.
16. Specify the data source as workflow Context, the Field source is the Workflow “Current User” , and Return Field as “Login Name”. Click OK, OK and OK.
17. The Action should be looking like this now.
Voila, Now you have your custom task that will be sent to the user’s manager with a notification in his task list.