cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Rick72
Level 10

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
HughOfficer
Level: Powered On

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

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?

Rick72
Level 10

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

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

rmayerle
Level: Powered On

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.

rmayerle
Level: Powered On

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.



"....

bolin-stratus
Level: Powered On

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)

 

bolin-stratus
Level: Powered On

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 )
Suvarna
Level: Powered On

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
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 (5,247)