-2

I am beginner in salesforce. I have a visualforce page where i am displaying all the collaboration groups. Can anyone guide me to display inherent Join Button for groups in that page?

Thanks!!!

1 Answer 1

0

You can use CollaborationGroupMember or CollaborationGroupMemberRequest according to Collaboration Group's status (public, private). You need to add a method in your visualforce page controller.

//vf page

<apex:commandButton action="{!add}" value="Join"></apex:commandButton>

//controller

public PageReference add(){
  if(collaborationGroup.CollaborationType == 'Public'){
    CollaborationGroupMember cgm = new CollaborationGroupMember();
    cgm.CollaborationGroupId = collaborationGroup.Id;
    cgm.CollaborationRole = 'Standard';
    cgm.MemberId = user.Id;
    insert cgm;
  }else if(collaborationGroup.CollaborationType == 'Private'){

    CollaborationGroupMemberRequest cgmr = new CollaborationGroupMemberRequest();
    cgmr.CollaborationGroupId = collaborationGroup.Id;
    cgmr.RequesterId = user.Id;
    insert cgmr;
  }

  return null;
}

More info on CollaborationGroupMember; link More info on CollaborationGroupMemberRequest; link

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .