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!!!
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