Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > Workflow: Next Approver is my VP
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
October 27
Workflow: Next Approver is my VP

Many times in approval workflows, the first approval needs to go to the employee’s manager, and then the next approval is supposed to go to the VP of that department.  The VP isn’t necessarily going to be your manager’s manager, though.  In SharePoint Designer 2010 workflows, information about users can be obtained within the workflow, which lets you look up, say, job title information.  This means that we can look to see if a manager has the text “VP” in their job title, to see if that’s the next person to route the item to for approval.

Your user profiles do need to have accurate information, in this case especially in the Manager field and the Job Title field.  Also, in this example I’m assuming that there won’t be any more than 4 levels between the workflow initiator and the VP of that department.  You can see the pattern that’s used and just add more levels if you need to.

As a very simple example, we have an item that routes like this:

  1. Initiator’s manager for approval
  2. The VP above the initiator’s manager for approval

After the VP’s name has been obtained, you can pretty much do whatever you need to do in the workflow, such as send them an email or assign a task. 

First, the following is the list of variables to create in the workflow:
ch5[13]
Then, these are the high level steps to go through:

Workflow Steps:

Find Manager of Current Item: Created By (output to Variable: manager)

IF User Profiles:Job Title (of the manager) contains VP

          Set Variable:VP to Variable: Manager

Else

          Find Manager of Variable: Manager, output to variable: SecondLevelMgr

          IF User Profiles:Job Title (of the 2nd level mgr) contains VP

          Set Variable:VP to Variable: SecondLevelMgr

          Else

               Find Manager of Variable: SecondLevelMgr, output to variable: ThirdLevelMgr

               IF User Profiles:Job Title (of the 3nd level mgr) contains VP

               Set Variable:VP to Variable: ThirdLevelMgr

               Else

                    Find Manager of Variable: ThirdLevelMgr, output to variable: FourthLevelMgr

                    IF User Profiles:Job Title (of the 4th level mgr) contains VP

                    Set Variable:VP to Variable: FourthLevelMgr

Now that you see the gist of how the workflow goes, I’ll get into some details about a couple of the actions used.

On each line that starts with IF, these are the steps to lookup that manager’s job title:

  1. Add a new condition called If any value equals value
  2. Click the first Value word, and click the little function button next to it.
  3. The data source is “User Profiles”, and field is “Job Title”.  In the section called Find the List Item, you’re matching up the Account Name with the variable called manager.
    ch5[14]
  4. When you click the function button next to the Value of “Find the list item”, use the following settings:
    ch5[15]
  5. Click OK to both of these dialog boxes, and you’ll be back on the workflow.  Click the word equals and change it to CONTAINS and then type VP in the box for the second value.  Therefore…
    ch5[16]

Okay, so that’s the most complicated part of the workflow, the job title lookup.  All the other steps are pretty much just as they’re written in the Workflow Steps text above.  I do like to use the “log to history” action a FindVPworkflowlot in my workflows, which helps with troubleshooting. 

Here’s an entire screenshot of the workflow in SharePoint Designer 2010.  Click to enlarge:

You’ll notice that I did put a bunch of logging in there.  Again, this workflow doesn’t DO anything in its current state, except obtain the VP’s login name and store it as a variable.  For this to be useful, it would just be a part of a bigger workflow.  You can send an email to the VP (the variable), or assign them a task, etc.

 

 

 

Comments

FAW

A trick we use because our user profiles are not set up to allow that kind of checking is to create a custom list to act as a routing table for our cost centers. It can be used by InfoPath or a SPD workflow.   For example, there's a cost center number, the cost center name, a manager's name (First Name, Last Name), their AD account (person field), their approval manager's name, the approval manager's AD account, and a few other things that are specific to our organization.    Start by selecting the correct cost center for what ever you need to do, and the form or workflow uses the routing table to send it to the correct approver in the correct order.   We have it so you can begin with a supervisor and up with the Board of Directors. Staff change? Update the routing table, leave the forms and workflows untouched.
Shane YoungNo presence information on 10/29/2010 10:59 AM

manny chohan (mannychohan@gmail.com)

Hey Laura,   I love your articles as they provide great insight into how to do lots of things in SP. I have a situation much similar to this blog post but the issue is that I am using Sharepoint Foundation and I am not able to tap into the UserProfile statement while creating workflow.  Is there any workaround this issue?  Thanks  Manny
Shane YoungNo presence information on 12/12/2010 1:12 PM

san

I could not find 'User Profiles' in Define Workflow Lookup's Data Source field..Could you please help me..
Shane YoungNo presence information on 2/7/2011 10:33 PM

Laura

Faw, Yes, that's definitely a feasible alternative.  Manny, Try doing what Faw said.  San, If you don't see it, that usually means you're not running the enterprise version of sharepoint 2010.
Laura RogersNo presence information on 2/22/2011 10:50 AM

Robert

Charming Laura,  I’m trying something similar to what you outline here but am seeing an error in the 14/logs when the workflow runs: “The user does not exist or is not unique”.   I confirmed the manager variable was correctly being set for CurrentItem:CreatedBy with a log entry (“DOMAIN\FLastName” was logged) and I confirmed I’m specifying the Return field as “Login Name”.  I’m suspecting setting the Approver value with the manager variable is where this error is occurring (or possibly it is not being set), but would like to see if you have any insight on this.  I’ve modified the OOTB Approval workflow and before Step 1, I’ve added the step to set the Parameter:Approvers to the managers that looks like this:     Find Manager of “Current Item:Created By” (output to Parameter:Approvers)  Is placing steps before the first overall workflow task not setting the Approvers value soon enough?  I've included a link to a forum entry where I've investigated other possible reasons for the error.
Shane YoungNo presence information on 4/7/2011 12:03 PM

Laura

Robert, I don't know, but here's how you can troubleshoot it.  Set logging in the WF.  add this action: Log to history: "the manager is... [then add the lookup to the user's manager] That way you can see what it's returning, before you try to send an email or anything.
Laura RogersNo presence information on 4/21/2011 9:26 PM

Moyo

Nice work Laura.. keep it up
Shane YoungNo presence information on 9/1/2011 4:09 PM

RG

Hi Laura,   First of all, I love your blog. It helped me a lot.   I have a question:  I’m using SPD 2007; do I need to change something in this workflow? I’m trying to combine this workflow with your article “InfoPath User Roles in Browser-Based Forms- Another Way”. Do you have any suggestions about how to do that?  Thanks in advanced.   RG
Shane YoungNo presence information on 11/8/2011 6:42 AM

Laura

RG, Use the userprofileservice.asmx with the GetUserProfileByName operation.  Pull in the user's Title property.  Then you can do a rule on any control that looks to see if Title contains "VP".
Laura RogersNo presence information on 11/11/2011 8:17 PM

Darren

Hi Laura, I am having the same issue as San where I cannot find 'User Profiles' in Define Workflow Lookup's Data Source field.  We are running SharePoint 2010 Enterprise.  Any other ideas as to why this is not running?  Our user profile service is running and my sites are working.
Shane YoungNo presence information on 12/16/2011 1:09 PM

Laura

Darren, Make sure that the sharepoint enterprise site feature is activated on your site.
Laura RogersNo presence information on 12/19/2011 10:08 AM
​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