cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

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
Highlighted
Skilled Sharer
Skilled Sharer

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

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

Highlighted
Post Partisan
Post Partisan

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.

Highlighted
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

 

Highlighted
Skilled Sharer
Skilled Sharer

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

Highlighted
Post Partisan
Post Partisan

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?

 

Highlighted
Skilled Sharer
Skilled Sharer

Re: Visible button depending on user email

@Oskarkuus 

 

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

Highlighted
Post Partisan
Post Partisan

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 \

 

Highlighted
Anonymous
Not applicable

Re: Visible button depending on user email

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

Highlighted
Post Partisan
Post Partisan

Re: Visible button depending on user email

That worked

Thanks

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,268)