Skip to content

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.

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.

Check who’s in a group:

set team to mash.group("Finance")
each team.members as person
printline person.username
end

Add 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.")
  • Test for no match with null. mash.group("nope") is null. Reading .name on 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. addMembers raises an error. Change those in the directory.
  • A loop over members can include groups. Check a member’s type if you only want people.

mash.users, the Group type, and mash.mail.

groups.all(sync?: bool = false) → Collection

Get all groups.

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.