cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Oskarkuus
Level: Powered On

Visible button depending on user email

Hi
I have this code
If(User().Email = "user@domain.com", true)

It works when put in visibility function on a button.

But it does not work when changed to this
If(User().Email = "user@domain.com"or" user2@domain.com", true)

But i rather have a list in a gallery with email adresses
How to modify above code so it checks if the users email is located in gallery3.title
(datasource sharepoint list)


1 ACCEPTED SOLUTION

Accepted Solutions
panand99
Level 8

Re: Visible button depending on user email

@Oskarkuus 

 

You can do by these steps:

 

- create a collection on OnStart

ClearCollect(collAppUsers,UserList)

 

then create a local varialbe and sents its value

 

Set(IsUser,CountRows(Filter(collAppUsers,Lower(Title) =Lower( User().Email))) = 1)

 

Then, on visible of field :

if(IsUser,true,false)

 

 

Please mark it as a solution if it solve your query

10 REPLIES 10
Vasii
Level 8

Re: Visible button depending on user email

Hi @Oskarkuus 

 

could you try if it works with || instead of "or" like

If(User().Email = "user@domain.com" || " user2@domain.com", true)

 

Let me know if that works Smiley Happy

 

Best regards

Vasii

Oskarkuus
Level: Powered On

Re: Visible button depending on user email

No that does not work either.

 

That solution with a code is nice but i would really like to have it read from a list instead.

Something like this

If(User().Email = Gallery1.Title, true)

But i cant get either to work.

All that works is 1 email adress.

LouisC
Level 8

Re: Visible button depending on user email

Hi,

 

"Or" is a function in powerapps.

 

So, you can use it :

If(Or(User().Email = "user@domain.com",User().Email = "user2@domain.com"),true,false)

 

Does it work ?

 

Regards,

 

Louis

 

panand99
Level 8

Re: Visible button depending on user email

@Oskarkuus 

 

You can do by these steps:

 

- create a collection on OnStart

ClearCollect(collAppUsers,UserList)

 

then create a local varialbe and sents its value

 

Set(IsUser,CountRows(Filter(collAppUsers,Lower(Title) =Lower( User().Email))) = 1)

 

Then, on visible of field :

if(IsUser,true,false)

 

 

Please mark it as a solution if it solve your query

Oskarkuus
Level: Powered On

Re: Visible button depending on user email

Id really like your solution to work.

But im not sure im doing this correctly.

ONSTART :

ClearCollect(collAppUsers;Administratörer_SystemApp) & Set(IsUser;CountRows(Filter(collAppUsers;Lower(Title) =Lower( User().Email))) = 1)

 

Administratör_SystemApp = sharepoint list with column TITLE containing email adress to users that should be able to view a button.

 

I suspect i should have the SET line somewhere else than on the ONSTART function?

 

panand99
Level 8

Re: Visible button depending on user email

@Oskarkuus 

 

just remove "&" and use ";" after your collecion creation

Oskarkuus
Level: Powered On

Re: Visible button depending on user email

Still get an error

ClearCollect(collAppUsers;Administratörer_SystemApp);Set(IsUser;CountRows(Filter(collAppUsers;Lower(Rubrik) =Lower( User().Email))) = 1)

 

Complains abotu the ;

it says something (roughly translated) about unexpected token, Expects \

 

LouisC
Level 8

Re: Visible button depending on user email

Try with ";;" -> it permit to execute many things

Oskarkuus
Level: Powered On

Re: Visible button depending on user email

That worked

Thanks

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 293 members 3,980 guests
Please welcome our newest community members: