Set a people field in SharePoint with Power Automate when all you have is a user’s name.

Have you tried updating a people field in SharePoint? It can actually be very simple. In my case all I had was a list of firstnames and lastnames of the people and I needed to update a list of items in SharePoint.

I will skip the reading the data for simplicity sake. I will start by setting a compose action to my first and last name.

Update a user field user Flow

Ok, this is simple enough. My run history shows that it all worked.

Update item worked and set people field in SharePoint

But now imagine that I have no user in some of my data. In my case the user field is not a required field. To simulate this I’m setting my compose to an empty string.

an empty string using the trim function

This will result in an error. Ok, this is easy enough to resolve. Just check for an empty user name and only do the update when the account is not empty.

 "message""The specified user  could not be found.\r\nclientRequestId: fd85ac1f-45b7-4c79-a9e6-8bc752746163\r\nserviceRequestId: f5709f9e-0079-0000-3740-57e8a2a27178"

Now the final challenge, how to handle invalid user accounts. I set my user account to John Johnson, and I’m getting the expected warning:

An Invalid user name

Microsoft flow has the Resolve Person action for this.

Resolve Person action

Note that before you can select the Column you will first have to select the view. It is a bit annoying that this option is available under the by default hidden advanced options. But this still doesn’t solve the problem. Invalid users will give the

Did not resolve to exactly one entity value. Number of values found: 0

 

#Result of Resolve user action when user doesn't exist

So we still need to do some more work! The flow below will work for existing accounts but not for invalid accounts. Did you consider conditions? Well you should not!

Update user flow

We need to set the Run after actions on the update item after the resolve person action.

 

Run after settings to ignore the failure

Once we have done that the flow will run successfully.

Showing the failed action but a successful flow

 

Other Posts about setting user fields

Get the user ID to update a people field in Microsoft SharePoint with Power Automate

 

One thought on “Set a people field in SharePoint with Power Automate when all you have is a user’s name.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: