Hi - I have an app which I want to use as a portal for guest users (customers) to access lists in our SharePoint site. I thought the app was working fine until I did the first set of user testing today.
I have two global variables (which work correctly). They identify if the user is an FIW Approver (in which case everything shows) or if the user is a customer they should only be able to see their own items. However, I have a gallery where the customer can see all items. Intuitively I know the code is wrong but I’m getting tangled in the syntax and can’t work out how to get it to work.
The incorrect code is this:
//If current user is approver show all
If(
gvCurrentUser = "FIW Approver",
SortByColumns(
Search(
If(
IsBlank(cbCustFilter_Ing.Selected.Value),
'Master Ingredients List',
Filter(
'Master Ingredients List',
Customer.Value = cbCustFilter_Ing.Selected.Value
)
),
TxtIngFilter.Text,
"Title"
),
"Title",
Ascending
),
//Else filter the data based on the customer logged in
SortByColumns(
Search(
If(
IsBlank(cbCustFilter_Ing.Selected.Value),
'Master Ingredients List',
Filter(
'Master Ingredients List',
Customer.Value = gvCustomer
)
),
TxtIngFilter.Text,
"Title"
),
"Title",
Ascending
)
)
I’ve tried playing around with the formula but I just keep getting lost in the syntax.
In another gallery, this works correctly. If the current user is not an approver they only see their ingredients with expiring or expired Halal certs. This is how I know the gv's are working as intended.
//If current user is approver show all, else filter the data based on the customer logged in
If(
gvCurrentUser = "FIW Approver",
SortByColumns(
Filter(
'Master Ingredients List',
(HalalStatus.Value = "Expired" || HalalStatus.Value = "Expiring") && Halal.Value = "Yes"
),
"Title"
),
SortByColumns(
Filter(
'Master Ingredients List',
(HalalStatus.Value = "Expired" || HalalStatus.Value = "Expiring") && Halal.Value = "Yes" && Customer.Value = gvCustomer
),
"Title"
)
)
Screenshot from user testing. The User is from Spring Sheep so should only be able to see Spring Sheep items in the gallery. They should still be able to search based on the text input of TxtIngFilter (ingredient name).

Can anyone help me?
GraemeNZ