In Salesforce Chatter Group represent a group of users. It’s a great way to boost collaboration in your organization. You can add unlimited members into Chatter Group, but a user can join maximum of 100 Groups. In Salesforce you can Clone records but not Chatter Group. In this article I will discuss how a Salesforce Admin can build an application using Flow to Clone Chatter Group.
Business Use Case
Higher management in Universal Container wants to a develop an automated process, so that they can easily clone Chatter Group with members instead of adding mass members through data loader into new group.
Solution for the above business requirement
To solve this requirement we will use Visual Workflow. Before proceeding you have to understand CollaborationGroupMember objects in Salesforce. We need these two values
1) CollaborationGroupId: – ID of the private Chatter group.
2) MemberId: – ID of the group member.
In our app on the first screen user will select an existing group he wants to clone and enter a few details for new group like Name, Description and Access. After that flow will create a new group and copy all members form selected (Existing) group. Now we will create a flow to the Clone Chatter Group with members. To do that 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.
3) Create Three text type variable NewGroupID, OldGroupID and LoggedInUserID (to pass Chatter New group Old group and logged-in user id in flow)
4) Drag and drop a Screen ( Give the name Clone Chatter Group) on window, add field Drop-down (Name – Select Group) Add dynamic choice as shown in below screenshot
5) Likewise you can add three fields
- Textbox field ( Give the name New Group name )on the same screen
- Long Text Area field ( Give the name Description )on the same screen
- Radio button field ( Give the name Select Access ) and add two value Public or Private on the same screen use
Finally our Screen will look like the below screenshot
6) Drag and drop a Record Create ( Give the name Create Chatter Group) onto the window to create a new Chatter group and map the fields according to below details
- Select Object CollaborationGroup
- CollaborationType= {!Select_access}
- Description ={!Description}
- IsAutoArchiveDisabled= {!$GlobalConstant.False}
- Title= {!New_Group_Name} , Save Id of record into any variable in our case it’s {!NewGroupId}. You can take help from the following screenshot
7) We also need the ID of the selected Chatter group for Clone . Drag and drop a Record Lookup( Give the name Find Old Group ID) and map the field according to the below screenshot, Save Id of record into any variable in our case it’s {!OldGroupID}
8) The next task is to get the list of the member id from the selected Chatter Group for cloning. To do this Drag and drop a Fast Lookup( Give the name Flookup) and map the field according to the below screenshot and save the details into SObject Collection in our case it’s {!MembersID}
Now you have a query why I included condition MemberId != {!LoggedinUserID} because when Chatter group is created by Record Create on step7, Owner is auto set to LoggedIn user.
9) Now our next task is adding members in the new group. For this we will use Loop, Assignment and Fast Create. To do this Drag and drop a Loop ( Give the name Extract members) and loop through SObject Collection {!MembersID} and save current value in New SObject Varibale {!MID} as shown in the following screenshot
10) Now Drag and drop an Assignment( Give the name Assign New Group ID) and assign {!NewGroupId} to SObject Varibale {!MID.CollaborationGroupId}, as shown in the below screenshot
11) Drag and Drop Assignment Logic (Give the name All in one) on the window and assign value from Sobject variable {!MID} to Sobject Collection Varibale {!Sov_NewMembers} so at the end of for loop (To avoid SOQL limit) it will add all members from old Public group to new Public Group. Take the help from the below screenshot
12) Finally add members into the new groups, by using fast create. Drag and drop a Fast Create( Give the name Add Members) and map the field according to the below screenshot
Finally our Flow will look like the following screenshot
12) Save the flow with name Clone Chatter Group and close the canvas.
Add Visual workflow into the home page component
We can call Flow from custom button, link, sub-flow, Visualforce page. Here we will call our Flow from the homepage component. To do that follow below instruction
- Create custom link from Name | Setup | App Setup | Customize | Home | Custom Link
- Add custom link in the Home page component
- Add Home page component into the Home page layout
It’s time to test feature
In this demo I will Clone Chatter Group “UC Internal Announcement“.
To open this app click on “Clone Chatter Group” link available on the homepage, and fill the details you can take help from below screenshot
Click on Next button and you are done. Below is the proof of concept