Hello PA Community,
I'm trying to create functionality on my app start page where certain buttons show up for certain users and other buttons show up for other users.
I created a simple, two-column lookup list in SharePoint that has a user's name and their designation. The two columns are UserName and UserAccessGroup
When the app starts it ClearCollects this list into a collection called UserAccess.
I'm trying to check if the User().FullName matches the collection's UserName column, and then if it's a match, a button will be visible or not dependent on his designation in the UserAccessGroup column. So, if the user is Susan Brown and her designation is "initiator" two specific buttons will show up but if the name is John Smith and his designation is "approver", another set of buttons will show up.
I've tried to set the button's Visible property to things like:
If(LookUp(UserAccess, UserAccess.UserFullName=User().FullName)&&LookUp(UserAccesss.UserAccessGroup="initiator", true, false)
but it's not working and I'm at a loss.
Any thoughts on how I can compare a User().FullName to two columns in a collection?
Solved! Go to Solution.
Hi @Anonymous,
I think you have some misunderstanding in the formula that I provided.
The formula that I provided is used to look up your UserAccess collection to check if there is a existing record whose UserFullName is current user and corresponding UserAccessGroup is "initiator". If the record is not existed, the LookUp function would return Blank.
In addition, you could also consider take a try with the following formula (set the Visible property of the two specific Button controls to following formula):
If( !IsBlank(LookUp(UserAccess,UserFullName=User().Email)) && LookUp(UserAccess,UserFullName=User().Email, UserAccessGroup)="initiator", true, false )
or
If( !IsBlank(LookUp(UserAccess,UserFullName=User().Email)), If( LookUp(UserAccess,UserFullName=User().Email, UserAccessGroup)="initiator",
true,
false ), false )
Best regards,
Kris
Hi @Anonymous,
I think there is something wrong with the formula that you provided. Please take a try to modify the formula within the Visible property of the two specific buttons to following:
If(
!IsBlank(
LookUp(UserAccess,UserFullName=User().Email&&UserAccessGroup="initiator")
),
true,
false
)
In addition, please also take a try to set the Visible property of the another set of buttons to following:
If(
!IsBlank(
LookUp(UserAccess,UserFullName=User().Email&&UserAccessGroup="approver")
),
true,
false
)
Best regards,
Kris
Hello Kris! @v-xida-msft
I gave your formula a try, and I think I'm getting closer, but here's a bit more info that might be causing the issue?
When I run the ClearCollect at the start of the application's run, it's pulling in the entire lookup table, data that includes both initiators and approvers. This lookup table is never going to be very large (15 people I'm guessing at the most) so I figured bringing it in at the app's launch every time is a good way to make sure if there are any changes to the lookup table, they'll be reflected in my collection.
So, if I'm understanding your formula correctly, it's looking to see if both the UserFullName and UserAccessGroup columns are not blank, thereby making the button visible, but both sets of buttons are staying visible because it pulls in all of both type of users.
Please let me know if I'm not interpreting your formula correctly, or, if you have the time, is there a way to only make the buttons visible if the current user's name is in the first column and their access group is one or the other?
Daniel
Hi @Anonymous,
I think you have some misunderstanding in the formula that I provided.
The formula that I provided is used to look up your UserAccess collection to check if there is a existing record whose UserFullName is current user and corresponding UserAccessGroup is "initiator". If the record is not existed, the LookUp function would return Blank.
In addition, you could also consider take a try with the following formula (set the Visible property of the two specific Button controls to following formula):
If( !IsBlank(LookUp(UserAccess,UserFullName=User().Email)) && LookUp(UserAccess,UserFullName=User().Email, UserAccessGroup)="initiator", true, false )
or
If( !IsBlank(LookUp(UserAccess,UserFullName=User().Email)), If( LookUp(UserAccess,UserFullName=User().Email, UserAccessGroup)="initiator",
true,
false ), false )
Best regards,
Kris
User | Count |
---|---|
124 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
214 | |
181 | |
140 | |
97 | |
83 |