Add the Manager automatically using Power Automate

Many times in our automation processes, we need to add the Manager of a specific user. Sometimes it’s just for reference, or the process will require an action from the Manager.  

Today, we’ll see how to add the Manager automatically in SharePoint using Power Automate.

SharePoint list

I have a SharePoint list called Employees containing (at least) 2 columns:

  • EmployeeName
  • Manager

Both columns are “Person or Group” fields.

Power Automate

For this demo, we’re going to use a manual trigger, but your process will likely require When a new item is created or another trigger depending on your requirements.  

In my scenario, I’ve already got the EmployeeName entered, therefore I want to go through them all and add the Manager. This scenario would be if you’re asked to add the Manager after the facts!  

So next, we’re going to use the Get items actions to retrieve our employee names. We’ll enter our Site Address and the List Name (Employees) parameters.

Apply To Each

Because our employee names are all there, we need to use an Apply to each action to first Get the user’s profile, and then Get the manager.

What we’d like to happen then is, use the Update item action for our Manager field to be… well… filled.

BUT at this point, if you run the flow, you may encounter an error!  Why? Because if your users don’t have a Manager associated to them, the flow will not be happy 🥺

Red everywhere… Not nice! So let’s counter that.

Due to the fact that the Manager column is a People or Group field, we cannot ask the flow to insert “N/A” instead, which would be text. We’re going to leave the field blank, but avoid getting a terminating error by configuring the Run after setting in a condition.  

First, add a Condition and move the Update item in the “True” area. The condition will read “if the Get Manager is not null, then update the item”.

BUT, we need to configure the Run After settings for that condition, otherwise we’re still going to hit a brick wall with the Get Manager action! 😬

So again, on that condition, select the Settings tab and make sure to select every checkbox. We want to run the condition no matter what, in order to decide what to do in case there’s no Manager.

Run the flow

Now when we run the flow, it runs successfully. We still see the exclamation mark when there’s no Manager, but the flow continues. In my case, it does nothing more, but you could decide to send the error to someone.

When there’s a Manager, the flow runs normally.

And the SharePoint list is updated 👍

Thanks for reading! 🙂

Discover more from Veronique's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading