cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SmileAndWave
Level: Powered On

Query Another SharePoint List

I have a number of things I need to do that I do not know how to do. I am a Nintex power user, but new to Flow. I understand the logic, but it's using the actions in Flow that confuse me.

I have a flow that runs on List A. I have a list of department heads on List B. I need to secure the item on List A that the workflow is running on and grant access to the department head in List B. So my logic is:

If Department on List A = Department on List B, get Department Head, set DeptHead variable with List B Department Head, grant access to DeptHead variable.

If this was Nintex I'd be done by now. I've Googled like crazy, but I see a couple of different ways to write the syntax and I'm not sure what to do. Can someone help me out? What is the Filter Query in my Get Items action supposed to look like?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Query Another SharePoint List

Hey @SmileAndWave 

So I have setup two SharePoint lists...

List A: Community - Departments Requests

1.png

NOTE: I renamed the standard 'Title' column to 'Department'... so 'Under the Hood' the internal column name is still 'Title'

List B: Community - Department Heads

2.png

NOTE: I renamed the standard 'Title' column to 'Department'... so 'Under the Hood' the internal column name is still 'Title'

The Flow configuration:

3.png

 

The Flow is triggered when an item in List A is added or updated.

It then queries the List B for any items where the department of the added / updated item matches the 'Department' value... this is configured in the filter query: Title eq '@{triggerBody()?['Title']}'

Note: The filter query uses the internal name 'Title' and not the display name of 'Department'

 

The 'Get Items' action returns a collection... it should only ever by a single entry, but that's still a collection... so when you select any dynamic data returned by the action, Power Automate will add a 'Apply to each' loop.

 

I've finally added a 'Grant access to an item or folder' action to grant the department head access to the item (The one which triggered the Flow run). All done!

 

However, this permissions model only works where the department heads don't have access to the List A by default... if they already have access you may need to use the Graph API to remove and add permissions or a third party connector.

 

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up

 

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Query Another SharePoint List

Hey @SmileAndWave 

I'm jus setting up an example for you... back in 15

Jay

Super User
Super User

Re: Query Another SharePoint List

Hey @SmileAndWave 

So I have setup two SharePoint lists...

List A: Community - Departments Requests

1.png

NOTE: I renamed the standard 'Title' column to 'Department'... so 'Under the Hood' the internal column name is still 'Title'

List B: Community - Department Heads

2.png

NOTE: I renamed the standard 'Title' column to 'Department'... so 'Under the Hood' the internal column name is still 'Title'

The Flow configuration:

3.png

 

The Flow is triggered when an item in List A is added or updated.

It then queries the List B for any items where the department of the added / updated item matches the 'Department' value... this is configured in the filter query: Title eq '@{triggerBody()?['Title']}'

Note: The filter query uses the internal name 'Title' and not the display name of 'Department'

 

The 'Get Items' action returns a collection... it should only ever by a single entry, but that's still a collection... so when you select any dynamic data returned by the action, Power Automate will add a 'Apply to each' loop.

 

I've finally added a 'Grant access to an item or folder' action to grant the department head access to the item (The one which triggered the Flow run). All done!

 

However, this permissions model only works where the department heads don't have access to the List A by default... if they already have access you may need to use the Graph API to remove and add permissions or a third party connector.

 

HTH

Jay

-------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.

If you like my response, please give it a Thumbs Up

 

View solution in original post

Highlighted
SmileAndWave
Level: Powered On

Re: Query Another SharePoint List

Hi! I just wanted to pop in and let you know that I have not had a chance to try this solution yet. I will tackle it this week and report back! Thank you so much!!

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,936)