cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
gavinleung
Level 8

Filter a Gallery based on a user role

Hi all, 

 

I have a Sharepoint list, which has the records for tasks:

Task 

Assigned To

Assignment Date

Standard Time

 

The users are within a team, and they have a common leader. The app that I'm going to develop is that the members can view their own tasks. I have done this part. 

 

But what about the leader can see all tasks? 

 

The user is identified by using User(), so I know who is using this app and I know this user is a member or a leader. 

 

Thanks,

Gavin

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filter a Gallery based on a user role

Hi @gavinleung 

Yes, it's possible to refer to another list. Let's suppose you have a list called LeaderList. This list stores the email addresses of the leaders in a column called LeaderEmailAddress. You can adapt the formula to refer to the LeaderList like so.

 

If(CountIf(LeaderList, LeaderEmailAdress = User().Email) > 0,
   TaskList,
   Filter(TaskList, 'Assigned To'.Email = User().Email)
)

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Filter a Gallery based on a user role

Hi Gavin,

Supposing that you're displaying your records in a Gallery control, you can control this by using an If statement in the Items property of the control. The formula would look something like this.

If(User().Email = "TeamLeaderEmailAddress@Domain.Com",
TaskList,
Filter(TaskList, 'Assigned To'.Email = User().Email)
)

If you are using User().Email to identify the user, I would also recommend that you store the email of the current user in a variable with the Set function and to refer to that variable in your formula. This can help mitigate any delegation problems that may arise.

Hope that's of some help.

gavinleung
Level 8

Re: Filter a Gallery based on a user role

Thanks @timl . But instead hard code, can I refer to another list or a table ? If so, how it can be done ? 

Super User
Super User

Re: Filter a Gallery based on a user role

Hi @gavinleung 

Yes, it's possible to refer to another list. Let's suppose you have a list called LeaderList. This list stores the email addresses of the leaders in a column called LeaderEmailAddress. You can adapt the formula to refer to the LeaderList like so.

 

If(CountIf(LeaderList, LeaderEmailAdress = User().Email) > 0,
   TaskList,
   Filter(TaskList, 'Assigned To'.Email = User().Email)
)

View solution in original post

gavinleung
Level 8

Re: Filter a Gallery based on a user role

I got it done ! Thanks @timl 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,887)