Security Filter to limit products displayed

Hi Community, I am trying to implement a security filter that can limit the products listed in the Products table to only the products that are associated to the users location. There will be 5 locations using the app. They can all order from the same vendors BUT some of the products will be specific to each location & some will be common amongst all or some of the venues. I have added an ENUM List (type Ref) in the Products table to the Venue table where I will assign the Venue to the product. I have a Users table & a Current_Users slice which I am hoping I can use to limit the products by the signed in User’s Venue. I am really struggling with the correct expression & syntax to get this to work. Any tips, tricks or improvements to the approach will be appreciated. Cheers Brad Additionally each user should have the ability to set whether the product is a “favourite” & this will form the basis of the ordering list. So essentially only the products appicable to the users venue must be visible & then I want to create a slice based on the “favourite” field value. Cheers

I am attempting the logic of the security filter expression by starting to write it & testing the part that should filter the data to the current users location:
IN(ANY([linkVenue]),Current_User[linkVenue])
(where the first instance (Products table) of linkVenue is the EnumList type Ref based on the Venue table & the second instance (Users table) is the Ref to Venues)
to test which products are assigned to the current users location. The problem I am running into is that when there are multiple venues assigned to a product the expression returns a false instead of true because one of the values is present in the list of venues assigned to the product. Any tips or tricks here? Cheers Brad

Does each user only have 1 location?

IN( ANY( Current_User[linkVenue] ) , [linkVenue] )
1 Like

Yeah the signed in user is associated with a single venue.

I have a security filter working which checks the current users venue value to the list of venues assigned to a product & only displays the valid products if the users venue is in the list…
IF(
IN(ANY(Current_User[linkVenue]),[linkVenue]),
true,false)
Perhaps there is a better way to do this? Cheers

IF( condition , true , false)
is exactly equivalent to just:
condition

2 Likes

Thanks @Marc_Dillon I have simplified the expression to just the condition & will look at modifying it as needed for other conditions. I appreciate the help. Cheers

1 Like