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
MissaJMissaJ 

New Users to Auto Join a Group via a Trigger

I am trying to write a trigger to auto join a group with a trigger.  Can Groups be joined/followed via a trigger yet?

Best Answer chosen by Admin (Salesforce Developers) 
cloudcodercloudcoder

If I understand your requirement correct, you don't actually want a trigger on groups, you want a trigger on some action which indicates some user should be added to a group. Something like upon the creation of a User perhaps? If that is correct in your scenario,you would need a trigger on the User object, and a little bit of Apex to insert a record in the Chatter Group (look at the CollaborationGroup object for where to insert)

 

LMK if I misread your requirements.

All Answers

cloudcodercloudcoder

If I understand your requirement correct, you don't actually want a trigger on groups, you want a trigger on some action which indicates some user should be added to a group. Something like upon the creation of a User perhaps? If that is correct in your scenario,you would need a trigger on the User object, and a little bit of Apex to insert a record in the Chatter Group (look at the CollaborationGroup object for where to insert)

 

LMK if I misread your requirements.

This was selected as the best answer
MissaJMissaJ

You got it correct.  I was actually able to get the code towork last night. I just had not had time to come back and update.  Thanks for replying.

SalesforceDF2011SalesforceDF2011

Hi,

 

Do you mind sharing the code to automatically add a new user to a group on creation.

 

Thanks!

SF7SF7

Could you please tell us how you did this