I have an app I want to assign each user to a group (sales, management, janitorial), etc

I have an app I want to assign each user to a group (sales, management, janitorial), etc. But some users can belong to more than one group (ie., sales manager). What’s the best way to accomplish this?

You could use roles https://docs.glideapps.com/all/topics/security-and-user-data/roles

Does not quite fit. There are a dozen groups. This is not about security. It is groups of people with similar interests. I was just giving examples.

Not sure exactly what you’re after, but simplest way would be to use choice component with multi-select enabled picking from a list of groups in a separate table. This would give comma-separated list of group names per user.

2 Likes

Thank you. It does that. So each user has a group or set of groups. Then I have other entries that will allow them to select which group(s) they want the entry to appear for. It filters to only allow them to select their group(s).
But when filtering the other entries, I cannot just say “groups = user>groups” because they don’t necessarily match all items. For example, I would want any user who has “man’s club” as one of his groups to see any entry in this list that contains “man’s club”.

image

I am guessing I will need a calculated column which “explodes” the entries in both the user table and the “entries” table so they can be filtered correctly. I am not seeing very good documentation on the array column, but I’m not sure that’s where I need to be looking anyway. If I have a user whose groups are “man’s club, value seekers” how do I filter the entries so that the user will see all entries that have “man’s club” in them. Right now, the user who’s groups are “man’s club, morale” only sees that one entry.

In point of fact, I did a split text, and then did a relation column based on that and got:

image

At which point I did a lookup column and got the email addresses (not pictured), which I assumed I could put a filter on (USER>EMAIL is included in … ), but the only thing the filter allows me to do with Group Relation and Group Lookup is “Is Empty” or “Is Not Empty”…

So I am still stuck.

Well, it seems the solution is then to use the lookup to find an array index value based on the user’s confirmed email. Then I can check for not empty and it shows me the correct entries by user. Pretty convoluted way of getting there, but it works…

A less convoluted way could be to create a relation from your Group table to your Users table, that links the Group name to the Split Text column in your Users table. You could then use that relation column as a filter, ie. only show groups where the relation is not empty.

That relation would have other uses. For example when viewing a Group, that relation would provide access to a list of members of that Group.

For what it’s worth, I would have done this the other way around. Instead of a column in the Users table with a list of groups, I’d have a column in my groups table with a list of users (UserID’s, actually). With this approach, you could filter directly on that column - “Groups->UserID’s includes current UserID”.

3 Likes

Thanks for the input. The problem is the only two tables I actually have access to at the point of the filter is the user table and the Entries table, both of which have a groups column based on the groups table. I wish Glide would give us access to all tables from everywhere, and then this relation column that you suggest in the groups table would actually work.

I like your idea of a user array in the groups table except for the fact I have a dozen groups and perhaps 1000 users. And again, I don’t have access to the groups table in the filter. I only have access to the Entries table and the User table.

Or is this just a shortcoming with the free version?

That’s not really a problem. I’ve used a similar approach in a number of apps, with similar numbers.

Maybe I’m misunderstanding, but the way I’ve read it your goal is to present a group filter when a user is viewing entries, but only include those groups of which the user is a member of, yes?

If that’s the case, then I’d imagine that you’re using a choice component as a filter?
What are you using as the source for that choice component? Surely the Groups table?
In which case you should have direct access to the Groups->Users column to filter the groups in the choice list.

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