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

How to add permission to Salesforce Chatter Collaboration Group sOject?

I have communities enabled in my org and i have a class which will auto add the new registered member to a chatter group.

    CollaborationGroupMember cand = new CollaborationGroupMember(CollaborationGroupId=groupId, MemberId=UserId);
     try {
               insert cand;
                System.debug('Success insert cand >>'+ cand );
         }catch(DMLException e){
             System.debug('There was an error with the invite: '+e);
but when i execute the code it give me this error -> "Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Entity is read-only: CollaborationGroupMember: []"

I am guessing my communities default Guest account doesnt have the right to insert new collaborationgroupmember record. is there a way to extend this permission for this guest profile?

AmitAmit (Salesforce Developers) 

Please refer following links for more information :
Did you ever figure out how to get this working, as intended?  Your communities default Guest account adding a new user to the a Chatter Group.