Tag Archives: Chatter Group

Create Chatter Group Using Apex

Sample Code:

//Create a chatter group
CollaborationGroup gp = new CollaborationGroup();
gp.Name = 'Test Group';
gp.CollaborationType = 'Public';//It can be 'Public' or 'Private'                   
insert gp;
 
//Add member to above created chatter group
CollaborationGroupMember gpMember = new CollaborationGroupMember();
gpMember.MemberId = userId;//User id which you want to add
gpMember.CollaborationGroupId = gp.Id;//Above created group id
insert gpMember;