Pergunta

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?

Foi útil?

Solução

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top