Group Member rows are usually managed by editing a Public Group in Setup. The flow below covers adding members through the standard interface. For hundreds of changes, use Data Loader against the GroupMember object instead, since the UI is built for handfuls, not bulk.
- Open Public Groups
From Setup, enter Public Groups in the Quick Find box and select Public Groups. Click New to create a group, or Edit next to an existing group to change its membership.
- Name the group
Set the Label, which is the display name, and confirm the Group Name, which is the API name. These identify the group in sharing rules and in queries against the Group object.
- Choose the member type
In the Search dropdown, pick the member type you want: Users, Roles, Roles and Subordinates, or Public Groups. The available members list updates to match the type you chose.
- Add members and save
Select members from the left list and click Add to move them to Selected Members. Each entry becomes one GroupMember row on save. Click Save to write the membership.
The display name shown in Setup and in sharing rule pickers. Make it descriptive so the group's purpose is obvious at a glance.
The unique developer name used by the API and managed packages. It is generated from the Label but can be set deliberately for stable references.
When on, records shared with the group are also shared up the role hierarchy. Deselect it for very large groups like All Internal Users to keep sharing recalculation fast.
Controls which category of members the available list shows: Users, Roles, Roles and Subordinates, Public Groups, and portal types when portals are enabled.
- GroupMember cannot be updated. To move a user between groups, delete the old row and insert a new one rather than editing UserOrGroupId.
- Inserting or deleting GroupMember in the same Apex transaction as an Account, Contact, or User causes a mixed DML error. Move the group change into a future or queueable method.
- Adding a Role and Subordinates member grants access to everyone below that role too, which can be far more people than the role name suggests. Confirm the hierarchy before saving.
- You cannot hand-add users to a role pseudo-group through GroupMember. Change the user's role assignment instead, since that membership is computed from the hierarchy.