Microsoft Office 365

Filter by a SharePoint people field in Get items action in Power Automate

Filter queries in the Get items action in the SharePoint connector are quite easy, but what if you want to filter by a SharePoint People field?

The SharePoint people field setup

In SharePoint I’ve got a list that has a people field on it. This field is called Person1.

I now want to find all items in this list when a new item is added to the list that has the Person1 set to the same person as the Person1 field for the item just created.

So in short filter list items by a people field’s value found in SharePoint.

Get User ID

The flow will start with a trigger “When an item is create or modified. This will give me a user details for the Person1 field. The only thing that I will not get is the user id for the person1 user. But this is what I will need later.

A While ago I wrote a post about getting the user id for a user. In this post i’m going to use the same method again

The User It will be used later on so that I can build up the query that will look like this:

Person1Id eq 11

Person1 is my fieldname. The Id that follows this field name indicates that I query the ID of the person field. The 11 is the user id of my user.

We need to have a bit more of a detailed look at this code.

The trigger gives me the email address of the user selected in the Person1 field. Now i can query the User information List using the user’s email address.

And finally I’m getting the query completed by using the user returned in the first Get Items action. I will only ever get one user returned, therefore I can safely take just the first item in the array, avoiding on of those unnecessary apply to each steps.

The code used in this last step is:

first(body('Get_items_-_User_ID')?['value'])?['ID']
Share
Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

Recent Posts

Introducing 8 AI Functions for Dataverse in Power Apps

Recently Microsoft added AI Functions to Dataverse that can be used in Power Apps. In…

19 hours ago

Copy and paste Scope steps in the new Power Automate Designer

One of the outstanding issues with the new Power Automate Designer is Copy and Paste…

1 week ago

Receive the available storage within your SharePoint Online tenant

Within the SharePoint admin centre there is that little detailed overview, telling you the available…

4 weeks ago

Options for Documenting Your Power Apps: Comments, Code, and Controls

Within Power Apps there are various ways to document your app. In this post I'm…

1 month ago

2 ways to duplicate SharePoint Lists to support your Power Apps

Recently I've been asked quite a few times to duplicate SharePoint lists as part of…

1 month ago

Update a Hyperlink Column in SharePoint with Power Automate

Today, I was asked about how to create a lookup to a document or item…

1 month ago