cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SmileAndWave
Helper I
Helper I

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

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
Jay-Encodian
Super User II
Super User II

Hey @SmileAndWave 

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

Jay

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

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,427)