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 🙂

 

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
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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