function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cmchambecmchambe 

Custom field to trigger Public Group member

We have created a custom field in the User record which is a checkbox to tell us if someone is a people manager or not.  I'd like to automatically add all people managers to a Public Group.  Any tips?  Thanks!

Coco_SdyneyCoco_Sdyney

you will need to write a afterInsert trigger on User, if the custom field is true, perform below:

1. create a GroupMember 

2. set GroupId = to the public group Id you required

3. set UserOrGroupId to the user id that you are creating

4. insert the new GroupMember record into database