Groups
mash.groups · Platform
mash.groups looks up and creates groups, the lists of people that Foldr uses for permissions and shares. Use it to find a group, check who’s in one, or change its members.
How it works
Section titled “How it works”A name lookup can match several groups. Group names aren’t case-sensitive, and an LDAP group and a built-in group can share a name. mash.groups.get("Finance") returns a Collection of matches, empty when there’s none. mash.group("Finance") is the shortcut that hands back the first match, or null. Foldr ships two groups called “Foldr Users” on some tenants (one built in, one from the directory), so check type when it matters. A GUID returns the group directly.
members is a list of users and groups. It holds direct members only. A group inside the group appears as a Group and isn’t expanded. When you pass a group to mash.mail.send, its members are mailed (as blind copies), at most 500 in one message.
Changing a group is checked. addMembers, removeMembers and save need the permission to manage groups. A script run by a user can’t change a group that holds more rights than it does.
Common tasks
Section titled “Common tasks”Check who’s in a group:
set team to mash.group("Finance")each team.members as person printline person.usernameendAdd someone to a group:
set team to mash.group("Finance")team.addMembers([mash.users.get("sam.patel@example.com").first()])Tell the whole team:
mash.mail.send(mash.group("Finance"), "Month end", "The ledger closes tomorrow.")Watch out for
Section titled “Watch out for”- Test for no match with
null.mash.group("nope")isnull. Reading.nameon it fails. mash.groups.all()is for administrators. A script run by a user is refused.- You can’t add members to a directory (LDAP) group.
addMembersraises an error. Change those in the directory. - A loop over
memberscan include groups. Check a member’s type if you only want people.
See also
Section titled “See also”mash.users, the Group type, and mash.mail.
Methods
Section titled “Methods”groups.all(sync?: bool = false) → Collection
Get all groups.
create
Section titled “create”groups.create(data: array) → Group
Create a new group.
groups.get(string?: string, type?: string) → Group
Look up a group by GUID or name.
groups.make(data: array) → Group
Make a new group instance from data.