cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

Filter Gallery Based On User's Scope

Hi All. I'm having a brain fart here.

 

I am building a solution that allows users with the right hub scope to be able to see particular items within a gallery. I have two SharePoint lists: Hub_Userlist and SummaryList. The scope is that the Module and Hub has to match between the two lists. 

List1Hub_Userlist  
Text FieldText FieldPeople Field (Single)People Field (Multiple)
ModuleHubHead of ProcessReviewer
InventoryABC Reviewer1, Reviewer2, Reviewer3, Me
CashABC Reviewer4
InventoryDEF Reviewer5
CashDEF Me

 

List2SummaryList  
Text FieldText FieldText FieldText Field
ModuleHubAmountComments
InventoryABC10 
CashABC100 
InventoryDEF20 
CashDEF200 


So within the gallery I would like to see this where ME is equivalent is to current user:

Desired Gallery Items  
ModuleHubAmountComments
InventoryABC10 
CashDEF200 


Here's what I have so far on a screen's OnVisible property:

ClearCollect(UserList,Hub_Userlist);
Set(_UserEmail, User().Email);
ClearCollect(_MyAccess, Filter(UserList, Lower(_UserEmail) in Reviewer.Email));

The collection _MyAccess is to return my only the records that contains the user's name. I believe the next step is to create a ForAll and search where Hub and Module matches the user's records but I'm not having success. Here's what I currently amd using for the ForAll loop:

Clear(_FilteredData);
ForAll(SummaryList, If(LookUp(_MyAccess, Hub = Hub, true) = true && LookUp(_MyAccess, Module = Module, true) = true, Collect(_FilteredData, {Hub: Hub, Module: Module, Amount: Amount})));

@RandyHayesHope you can help me out with this ^_^

EDIT: Figured out why it wasn't working. It's because Hub = Hub was referencing itself. I changed the field name from one of the list to Hub1 and it started to work. So question is this. Can I still use the name Hub in both lists and do comparisons between the two? Something along the lines of

If(Lookup(_MyAccess, _MyAccess.Hub = SummaryList.Hub, true) = true))

I know this doesn't work but maybe you have a solution for this.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Filter Gallery Based On User's Scope

@hnguy71 

You can actually go about this a couple different ways depending on your overall design.

A very quick answer is to consider this for your Gallery Items property:

Filter(List2, 
         !IsBlank(
               LookUp(List1, 
                            Module=List2[@Module]  && 
                            Hub=List2[@Hub] && 
                            User().Email in Reviewer).Module
                       )
         )

This will give you the filtered results that you want without the need for additional collections, forall's or other actions.

Depending on the overall size of the data you are dealing with, there could be some performance considerations needed down the road for pre-shaping the data to make the formula more efficient, but this is a good starting point to get what you need.

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

1 REPLY 1
Highlighted
Super User
Super User

Re: Filter Gallery Based On User's Scope

@hnguy71 

You can actually go about this a couple different ways depending on your overall design.

A very quick answer is to consider this for your Gallery Items property:

Filter(List2, 
         !IsBlank(
               LookUp(List1, 
                            Module=List2[@Module]  && 
                            Hub=List2[@Hub] && 
                            User().Email in Reviewer).Module
                       )
         )

This will give you the filtered results that you want without the need for additional collections, forall's or other actions.

Depending on the overall size of the data you are dealing with, there could be some performance considerations needed down the road for pre-shaping the data to make the formula more efficient, but this is a good starting point to get what you need.

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,101)