
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Recently I had a requirement from a client to create a list view that would only display task records appropriate to members of certain groups. The functionality was similar to the standard My Groups Work module, which uses the getMyGroups() function to return an array of group Sys IDs representing all of the user's group memberships. However, unlike the My Groups Work module, the groups on my client's task records were contained in a custom List field on the record rather than a reference field.
The My Groups Work module compares the value in the task's Assignment group field with the user's group memberships by using the is operator:
This works fine for comparing a single value from the Assignment group field to the array of groups returned by the getMyGroups() function. But what about a many-to-many comparison between the groups in my client's custom list field and the user's groups?
I could have written a custom function in a client-callable Script Include to return a list of group Sys IDs, but the answer turns out to be much simpler, and best of all, it's right in front of us. The contains operator will automatically perform a comparison between multiple values on each side of the condition, and if any matches are found the condition evaluates to true.
So, the next time you need to compare multiple values to each other, try using the contains operator in your list or other filter condition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.