0

I am customizing a SP form with PowerApps called Requests. This is one of my first PowerApps forms, so please keep that in mind. Currently, I am trying to hide a button/label to only display based on particular users. I've decided to do this by creating a SP List that contains the user emails for the individuals whom need to see the button. The list is called Admins. The list has one column entitled 'Title.' This column contains the email addresses of the individuals that need to view the button.

In my PowerApps form, I am doing some general testing to ensure that values are returned from the Admins list. I have made two connections -- one to the SP form that I am customizing, and one to the Admins list which holds the emails.

In the app, I have created a function that sets a variable when it loads. Onstart = Set(varEmail, User().Email) to store the logged in user's email address. On the button/label that I wish to hide/show based on the email, I have added a function to lookup the email addresses from the Admin List, check if the variable equals the current logged in user's email address and hide the button accordingly. I have used this code on the label text field to test: LookUp(Admins, Title = varEmail).Title It does not print anything out such as an email address. Instead, it returns a blank value even though the list has been populated. When I've used the IsBlank function to test if there are blanks, it returns true. I've refreshed the connection and this still is happening.

What am I doing wrong?

0

2 Answers 2

1

Try the formulas below. I’ve tested and it works for me:

App: OnStart = Set(varEmail, User().Email)

Button/Label: Visible = If(Not(IsBlank(LookUp(Admins, Title = varEmail))),true,false)

Reference: If Statement Lookup for list record.


UPDATE: Here’s the explanation based on my understanding:

So we set a variable for the current user’s email address by Set(varEmail, User().Email) via Run OnStart.

  • Button.Visible = If([Condition], true, false)

  • Condition = [varEmail is one of the values in the Title filed of another list]

The formula for LookUp function is LookUp(Table, Formula). The function returns the first record that results in true in every record of the source Table.

(The one you use LookUp(Admins, Title = varEmail).Title is not valid. That is why it doesn’t print anything out.)

In this scenario, if the email address of the current user exists in the list Admin, it returns the email address. Else, it returns nothing/blank.

So we use Not(IsBlank(LookUp(Admins, Title = varEmail)) as the condition to identify if the LookUp function has returned blank. When Not(IsBlank(LookUp(Admins, Title = varEmail)) = true, Button.Visible = true.

So the full formula would be

Visible = If(Not(IsBlank(LookUp(Admins, Title = varEmail))),true,false).

3
  • @Chelses_MSFT Hi, thanks but this isn’t really helpful for me. I’m not looking for someone to give me a formula for the visibility portion. Can you provide more context? I specifically am trying to figure out why the LookUp formula above does not print out the email where I feel it should. Copying & pasting doesn’t help me understand the issue so I’m knowledgeable for the future. Mar 20, 2020 at 11:29
  • 1
    @user2004758 I’ve modified the answer to include more information. Please see the update. Mar 24, 2020 at 9:50
  • Thank you so much Chelsea. This was really helpful! I actually realized I made a typo in my actual formula & that was the issue. Thank you for breaking it down, as I have more understanding of the IsBlank function <3. Mar 25, 2020 at 1:56
1

Just a quick note, you can make the visibility property cleaner by the following:

Not(IsBlank(LookUp(Admins, Title = varEmail)))

IsBlank will return a boolean value, so there is no need to wrap it in an If statement. Also, since Not() can be replaced with !, you can also use it here to tidy up the statement further.

!IsBlank(LookUp(Admins, Title = varEmail))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.