These days Organization are using Chatter Group to boost their internal Collaboration. There are few ways to add New Users into Chatter Group
1) Manually add Users into Chatter Group
2) Automatically Add New User to Chatter Group
3) Send an email to them with Chatter Group link to join Chatter Group, So as soon User clicks on the link they will auto join Chatter Group. You can also use this technique to promote your Chatter Group.
In this article I will discuss how you can provide a link to join Chatter Group in an email to your users, So they will Join Chatter Group as per their interest.
Business Use Case
Management in Universal Container wants to send an email to their Salesforce users with a link to join new Chatter Group “Dreamforce14“, so they will auto join “Dreamforce14” Chatter group as soon as they click on the link provided in the email.
Solution for the above business requirement
To solve this requirement we will use Visual Workflow. We will create an app using Flow to fire this flow will use Visualforce Page. Before proceeding you have to understand CollaborationGroupMember objects in Salesforce. It represents a member of a Chatter group. We need these two values
1) CollaborationGroupId: – ID of the private Chatter group.
2) MemberId: – ID of the group member.
To develop this application follow the below instructions
1) Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2) Click on New Flow, it will open flow canvas for you. Create Two Text type variable UserID (To pass Logged-In user id) and CurrentMembershipStatus (To store Logged-In user’s current membership status for Chatter Group Dreamforce14 ) as shown in the below screenshot
3) Drag and drop a Record Lookup ( Give the name Find Current User Member Status) onto the window to get Logged-In user’s current membership status for Chatter Group Dreamforce14 and map the fields according to below details
- Select Object CollaborationGroupMember
- CollaborationGroupId= Id of the Chatter group Dreamforce 14
- MemberID= {!UserId} [ This is nothing but Logged-In user ID], Save Id of record into any variable in our case it’s {!CurrentMembershipStatus}. You can take help from the following screenshot
4) Now Drag and Drop Decision element (Give the name Create Or Ignore) on the window to check whether Variable {!CurrentMembershipStatus} is null or not null. If the variable is null = True it means the user is not a member of the Dreamforce14 Chatter Group
5) Drag and drop a Record Create( Give the name Chatter Follow) onto the window to join Logged-in user to the Dreamforce14 Chatter Group and map the fields according to below details
- Select Object CollaborationGroupMember
- CollaborationGroupId= Id of the Chatter group Dreamforce 14
- MemberId= {!UserId} [ This is nothing but Logged-In User ID]. You can take help from the below screenshot
6) Drag and drop a Screen ( Give the name Show Message) on the window, to show the message If logged-In user is already member of the Dreamforce14 Chatter Group. You can take help from the following screenshot
7) Finally, our Flow will look like the following screenshot
8) Save the flow with name Dreamforce14 and close the canvas.
Add Visual workflow into Visualforce Page
To use this app creates one Visualforce Page and add your flow into it. Below is the sample code for your reference
In the above code, I used the ID of Chatter Group Dreamforce14 to auto redirect to Chatter Group home page as soon as the flow execution will be completed.
Note: – Grant this Visaulforce Page access to respective profile. Not sure about how to do that take a look of help article http://goo.gl/AwbtDO
It’s time to test this feature
1) In this demo I am using Read Only user to test this feature, for more information take a look of the following screenshot
2) Currently the user is not a member of Chatter Group Dreamforce14, for more information take a look of the following screenshot
3) Now login through Demo user and click on the link mentioned in the email and see the magic
4) Below is the Proof of concept for your reference
P.S. :- I will suggest you to Implement this first on your developer org test it and then move it to Production. Let me know if you have any difficulty to Implement it.