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

Or Sytax

I discovered that || does not work for all situations. I was trying to use a very commonly referenced technique to hide buttons based on who is the current user. My statement did not work and I could not figure out why. I am still not sure why it does not work since all the documentation from Microsoft that I have read says || is the correct thing to use in this case. 

 

Visibility=If(User().email = "name1@company.com"||"name2@company.com"||"name3@company.com",true,false)

 

I found the solution on a different community entry. The following worked.

 

Visibility = if(User().email in [ "name1@company.com", "name2@company.com", "name3@company.com"],true,false)

 

I would love if someone could tell me why the second option worked and the first did not. Also, I would love to get a link to the most recent pdf that gives all acceptable syntax options.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Or Sytax

Hi @lawsonbe2018,

The difference between the two formulas is that the first one requires that the User().email is identical to name1@company.com while the second one only requires that User().email is contained within the text "name1@company.com" of one of the elements in the right side of the comparison .  One reason for this behaviour is that there is a leading or following blank space that makes the two expressions look the same but are not actually identical.  One way to elimiante this possibility is to use the Trim() function on both sides and see if it works.  You could also parse your expressions by getting rid of the "It(), true,false)" since the result of the formula reduces to either true or false anyway.  If you have more than one comparison, you can wrap them all in one Or() function also instead of using ||.   

Trim(User().email) = Or(Trim("name1@company.com"),Trim("name2@company.com"),Trim("name3@company.com"))

 It would probably be preferable to use the first formula if you could get it fixed because the "in" operator is not always delegatable and may produce a warning.

3 REPLIES 3
Super User
Super User

Re: Or Sytax

Hi @lawsonbe2018,

The difference between the two formulas is that the first one requires that the User().email is identical to name1@company.com while the second one only requires that User().email is contained within the text "name1@company.com" of one of the elements in the right side of the comparison .  One reason for this behaviour is that there is a leading or following blank space that makes the two expressions look the same but are not actually identical.  One way to elimiante this possibility is to use the Trim() function on both sides and see if it works.  You could also parse your expressions by getting rid of the "It(), true,false)" since the result of the formula reduces to either true or false anyway.  If you have more than one comparison, you can wrap them all in one Or() function also instead of using ||.   

Trim(User().email) = Or(Trim("name1@company.com"),Trim("name2@company.com"),Trim("name3@company.com"))

 It would probably be preferable to use the first formula if you could get it fixed because the "in" operator is not always delegatable and may produce a warning.

lawsonbe2018
Level: Powered On

Re: Or Sytax

Thank you for the response. That makes a great deal of sense. Is there a single resource that gives you correct information about these type of syntax issues or have you just come by this knowledge through trial and error?

Highlighted
Super User
Super User

Re: Or Sytax

A little of both. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/formula-reference will give you the syntax for all PowerApps functions. My experience with database design in MS Access helped and the videos and posts on the forum community blog are also great resources. Some of the resources to look for are from @KroonOfficeSol, @Meneghino, @Shanescows and @Audrie-MSFT.  I think those are the ones that helped me get started.  Since then I think I learned more by researching and finding answers for other forum posters like yourself. 

We are all students here. Some are a just little further down the path.

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: 36 members 3,986 guests
Please welcome our newest community members: