cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oskarkuus
Post Prodigy
Post Prodigy

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
Impactful Individual
Impactful Individual

@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
Anonymous
Not applicable

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

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

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
Impactful Individual
Impactful Individual

@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

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
Impactful Individual
Impactful Individual

@Oskarkuus 

 

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

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

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

That worked

Thanks

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,559)