cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Show/Hide Button based on email addresses in a Sharepoint List

Hello, 

 

I'm having trouble finding an answer to this. 

 

  • Sharepoint list named "accessList"
  • Person column named "name"
  • Button in PowerApps with Visibility property set to: 
    • If(User().FullName in accessList.name,true,false)

I want the button to only be visible to people in the list. 

I've also tried: 

  • If(Filter(accessList,name = User().FullName),true,false)

What am I missing to make this work?

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Impactful Individual
Impactful Individual

Re: Show/Hide Button based on email addresses in a Sharepoint List

Hi @ericonline,

 

I totally understand why you want this: Role Based Access Robot Happy

 

What works for me is:

1. Having a SharePoint list named 'Config'. This is only a "small" list with a few entries. The title field of an item contains one e-mail address.

2. Adding the following to the OnStart property of the first screen: 

Collect(SPListConfig, Config); Set(currentUser,User()) ; Set(varEmail,LookUp(SPListConfig,Title=currentUser.Email,Title))

3. Adding the following to a button:

If(IsBlank(varEmail),false,true)

 

Cheers,

Rick

View solution in original post

9 REPLIES 9
Highlighted
Frequent Visitor

Re: Show/Hide Button based on email addresses in a Sharepoint List

Try the if function in a different way not using the filter. Say like this - If(name = User().FullName),true,false). See if this works

Highlighted
Super User
Super User

Re: Show/Hide Button based on email addresses in a Sharepoint List

Hello, 

 

I appreciate the reponse. I couldn't get this to work. I tried the following: 

 

  • If(name=User().FullName,true.false)
  • If(accessList.name = User().FullName,true,false)

Any other ideas?

Highlighted
Impactful Individual
Impactful Individual

Re: Show/Hide Button based on email addresses in a Sharepoint List

Hi @ericonline,

 

I totally understand why you want this: Role Based Access Robot Happy

 

What works for me is:

1. Having a SharePoint list named 'Config'. This is only a "small" list with a few entries. The title field of an item contains one e-mail address.

2. Adding the following to the OnStart property of the first screen: 

Collect(SPListConfig, Config); Set(currentUser,User()) ; Set(varEmail,LookUp(SPListConfig,Title=currentUser.Email,Title))

3. Adding the following to a button:

If(IsBlank(varEmail),false,true)

 

Cheers,

Rick

View solution in original post

Highlighted
Super User
Super User

Re: Show/Hide Button based on email addresses in a Sharepoint List

@Rick72

 

NICE! Thank you for the lead. With one minor tweak, I was able to get your solution to work: 

 

Because the column in my sharepoint list was a Person -type column (named "emailAddress"), I had to append ".Email" to the code as follows: 

 

Collect(SPListConfig, Config); Set(currentUser,User()) ; Set(varEmail,LookUp(SPListConfig,emailAddress.Email=currentUser.Email,emailAddress))

 Thanks again Rick. You solved for using a Sharepoint list for PowerApps access. Hope others find this post and can use this as well. Its a super powerful way for users to manage their own permissions. 

 

Take care

Highlighted
Regular Visitor

Re: Show/Hide Button based on email addresses in a Sharepoint List

I have recently used this example in one of my apps and it works well. One question I am trying to figure out is why you have to make a collection at all. Why cant the SP List "Config" be used for the lookup instead of the LookUp. It seems to me that it should work, but when I try this it doesn't.

Highlighted
Regular Visitor

Re: Show/Hide Button based on email addresses in a Sharepoint List

Sorry and that should say "Why cant the SP List "Config" be used for the lookup instead of the


@rmayerle wrote:

I have recently used this example in one of my apps and it works well. One question I am trying to figure out is why you have to make a collection at all. Why cant the SP List "Config" be used for the lookup instead of the LookUp. It seems to me that it should work, but when I try this it doesn't.



"....

Highlighted
Helper V
Helper V

Re: Show/Hide Button based on email addresses in a Sharepoint List

 


@HughOfficer wrote:

Try the if function in a different way not using the filter. Say like this - If(name = User().FullName),true,false). See if this works


@HughOfficer 
 I have a similar issue but I want to show/hide content based on a short list of emails. The top example works but the bottom example does not. What am I missing?

// Wks
If( User().Email = "first.last@company.com", true, false)

// Doesnt wk
If( User().Email = "first.last@company.com" || "first2.last2@company.com", true, false)

 

Highlighted
Helper V
Helper V

Re: Show/Hide Button based on email addresses in a Sharepoint List

I can use this approach but it seems like there would be a shorter method since I will have about ten emails to add.

// Wks
If( Or( User().Email = "first.last@company.com", User().Email = "first2.last2@company.com" ), false, true )
Highlighted
Regular Visitor

Re: Show/Hide Button based on email addresses in a Sharepoint List

You could use "in" to add multiple emails to your condition.

 

If( User().Email in ("first.last@company.com""first2.last2@company.com"), true, false)

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

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,092)