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 10

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

View solution in original post

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.

Anonymous
Not applicable

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 10

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

View solution in original post

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 10

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 \

 

Anonymous
Not applicable

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

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

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

Top Kudoed Authors
Users Online
Currently online: 351 members 5,363 guests
Please welcome our newest community members: