Hi,
Having some trouble achieving something at the moment; I've found a few very similar threads but nothing seems to work my side/hit exactly what I'm after.
I want to check, on load, whether the current user is a member of a list and depending on that result assign them a role.
I have a list called 'Admin' which is a simple one-column list containing a ~10 users; the datatype is Person/Group.
Currently I have the below in the OnStart section of my Form.
Set(currentUser, User())
A previous iteration also included UpdateContext({currentUser: User()}) but I can't see what, if any impact that is having on the logic.
I then have a Label with the text value of:
If(LookUp(Admin, currentUser.Email in User.Email),"Y","N")
I have also tried currentUser in User etc and also exposed the values in a gallery... If I apply the logic to the gallery it filters to show me the correct result but this doesn't help me in setting the value of a variable.
At this stage I just want to prove yes or no, is this user in this list but it returns blank regardless. Am I missing something very obvious here?
The next step would be to check that if the person is in the list assign them role X, if they're not, role Y.
Solved! Go to Solution.
Hi @BMarsh4,
Do you want to check if the current user is within your Admin SP list?
Is the User a Person type column which does not enable "Allow multiple selections" option within your SP list?
Based on the formula that you provided, I think there is something wrong with it. The first argument of the If function is required to provide a Boolean value, but the result your LookUp formula returned is a Record value.
I have made a test on my side, please take a try with the following workaround:
Set the OnVisible property of the first screen of my app to following:
Set(currentUser, User())
Set the Text property of the Label control to following:
If(!IsBlank(LookUp('20190122_case12', currentUser.Email in User.Email)), "Y", "N")
On your side, you should type the following:
If(
!IsBlank(LookUp(Admin, currentUser.Email in User.Email)),
"Y",
"N"
)
Above solution may cause a Delegation warning issue, in order to get rid of this issue, please take a try with the following workaround:
Set the OnVisible property of the first screen of your app to following:
ClearCollect(RecordsCollection, Admin)
Set the Text property of the Label control to following:
If(
!IsBlank(LookUp(RecordsCollection, currentUser.Email in User.Email)),
"Y",
"N"
)
Best regards,
Hi @BMarsh4,
Do you want to check if the current user is within your Admin SP list?
Is the User a Person type column which does not enable "Allow multiple selections" option within your SP list?
Based on the formula that you provided, I think there is something wrong with it. The first argument of the If function is required to provide a Boolean value, but the result your LookUp formula returned is a Record value.
I have made a test on my side, please take a try with the following workaround:
Set the OnVisible property of the first screen of my app to following:
Set(currentUser, User())
Set the Text property of the Label control to following:
If(!IsBlank(LookUp('20190122_case12', currentUser.Email in User.Email)), "Y", "N")
On your side, you should type the following:
If(
!IsBlank(LookUp(Admin, currentUser.Email in User.Email)),
"Y",
"N"
)
Above solution may cause a Delegation warning issue, in order to get rid of this issue, please take a try with the following workaround:
Set the OnVisible property of the first screen of your app to following:
ClearCollect(RecordsCollection, Admin)
Set the Text property of the Label control to following:
If(
!IsBlank(LookUp(RecordsCollection, currentUser.Email in User.Email)),
"Y",
"N"
)
Best regards,
@v-xida-msft Thank you!
I knew it would be something minor; I was assuming that because I expected a true result from the LookUp, this would be passing a boolean but makes sense that some clarification is needed.
Much appreciated!
User | Count |
---|---|
122 | |
87 | |
86 | |
75 | |
67 |
User | Count |
---|---|
214 | |
180 | |
137 | |
96 | |
83 |