Skip to main content

There are times when you need to build a workflow that goes up the management chain, assigning tasks.  With the Query User Profile action in Office 365, you can now start building that logic into your workflow.

 

Workflow Design

 

WorkflowDesign.png

 

How It Works

 

I started off this workflow with initializing some variables.  The first one will be used in the condition for the loop and the second, simply stores the current initiators email address in a variable because we can reuse that through the loop.

 

The only reason I'm using a State Machine in this workflow, is so that it's easier for me to take a screenshot of it and also to break up some of the workflow logic.

 

It's the right branch that does most of the workflow.  We are looking at going up the management chain, use data from the User Profile service.  The Loop action is what allows us to keep querying the user profile and it does this, based on the value of a yes/no (boolean) variable called boolContinue.  If it's set to "yes", which we did in the Init Variables states, it will continue looping.

 

Loop.png

 

Once inside the Loop, we perform the Query user Profile to get the manager of the current user we are dealing with.  The first time into the loop, the user we deal with is the initiator.

 

QueryUserProfile.png

The next action is an important one.  It is the Set a Condition.  This action checks to see if the manager we retrieved, actually contains some data.  If not, then the user we're dealing with doesn't have a manager and they are high on the organizational chart.

 

If we do have data, we want to remove some text from the beginning of the manager so that we are left with just the email address which we will use when we loop around and go back through the Loop.  The removal of that text is described in the previous post on querying user profile data.

 

Alternatively, if we don't have any data, which means we have reached the end of our management chain, we need to set our yes/no variable to No, so that the loop exits out.  We can use the Set a Variable action.

 

SetWorkflowVariable.png

 

Conclusion

 

With this post and the previous post, you can see how you can build out some very interesting workflow logic to design your business processes.  If you have any questions or suggestions, please comment.  The workflow described here is attached to this post.

Great job!


Reply