Show collection of users with any of a set of attributes, without showing the current user

I want to be able to show a Grid component with source table ‘Users’ that shows other users who speak any of the languages spoken by the current user. I do not want the component showing the current logged-in user in the grid.

I’ve managed to do this using filters with the OR operator, with a condition for each language spoken by current logged-in user, so something like this:

LangArray contains(UserProfile.lang1) OR LangArray contains(UserProfile.lang2) OR LangArray contains(UserProfile.lang3)

Of course, with this approach the component always includes the current user in the list, which isn’t ideal.

Is there a way to achieve what I want? The simplest solution would be for the filter to combine both AND and OR operators, but this doesn’t seem to be an option currently. Something like this:

user_id !== UserProfile.user_id AND (LangArray contains(UserProfile.lang1) OR LangArray contains(UserProfile.lang2) OR LangArray contains(UserProfile.lang3))

Thanks.

Unfortunately, for some reason Glide does not allow us to mix AND and OR logic so we have to utilize some workarounds and twist our logic around a bit to make it work.

You will need to move this logic into your user table. Maybe create an IF column that looks something like this.

IF email IS UserProfile.email Then false
ELSEIF LangArray contains(UserProfile.lang1) Then true 
ELSEIF LangArray contains(UserProfile.lang2) Then true 
ELSEIF LangArray contains(UserProfile.lang3) Then true 
ELSE false

This will give you a boolean that you can use for your filter. Just set your grid filter to check if the boolean is checked.

4 Likes

Thanks Jeff, this makes a lot of sense, will give it a try. Looking forward to the day when Glide offers more powerful filters!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.