Last Updated on February 10, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
How do you provide a way to clone Chatter group with members to your users?
Chatter Group is primarily geared towards boosting collaboration among users within an organization. Similar to a public group, a Chatter group comprises a set of users. Indeed, one can add unlimited users to a Chatter Group.
Some time you or users want to quickly create a Chatter group by cloning an existing Chatter Group. There are a few apps available on AppExchange for this purpose, but nothing comes out of the box. This article will create a screen flow that allows users to quickly create a Chatter group by cloning an existing Chatter group.
I have written a few articles on automating Chatter Group and automation. Why not check them out while you are at it?!
- Getting Started with Salesforce Flow – Part 26 (Automatically Add a Record to Chatter Group)
- Getting Started with Salesforce Flow – Part 34 (Post Opportunity Details to a Chatter Group)
- Getting Started with Salesforce Flow – Part 46 (Is Your Chatter Group Data Clean? No? Use Flow to Do So!)
- Getting Started with Process Builder – Part 18 (Auto Creates a Private Chatter Group )
- Getting Started with Process Builder – Part 24 (Automatically Add User to Chatter Group)
- Getting Started with Process Builder – Part 82 (Recipes for Automating Chatter Group Management)
- Getting Started with Process Builder – Part 92 (Streamline the Process of Auto-Adding Chatter Group Members to Public Group!)
Objectives:
This blog post will help us to understand the following
- Use a Screen a flow to take the user input to create a Chatter Group
- Learn how to work with the picklist component (Screen Flow)
- Learn how to use a Decision element to find whether a Record variable or a Record collection variable contains a record
- Find out how to use the Loop element to extract records from a record collection variable.
- And, last but not least, discover how to use the Create Records element to create multiple records (add user to new chatter group) at once (Bulk Safe)
Business Use Case
Brenda David is working as a System administrator at Universal Containers (UC). She has received a requirement from the management to create a wizard that allows users to create a Chatter Group with members by cloning them quickly.
Automation Champion Approach (I-do):
- Lightning Web Component
- Apex Code
- Data Loader
- AppExchange App
We will use Salesforce Flow to solve it.
Before proceeding, ahead, understanding CollaborationGroup and CollaborationGroupMember objects in Salesforce. It represents Represents a member of a Chatter group.
Field Name | Details |
CollaborationGroupId | ID of the associated CollaborationGroup |
MemberId | ID of the group member |
NotificationFrequency | The frequency at which Salesforce sends Chatter group email digests to this member. Can only be set by the member or users with the Modify All Data permission. The valid values are:
|
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 3 steps to solve Brenda’s business requirement using Screen Flow. We must:
- Salesforce Flow Steps: Define flow properties
- Add a screen to capture the user’s input.
- Add a screen to capture the user’s input for new chatter group
- Group Name
- Description
- Add a radio buttons to show two options for Automatic Archiving
- Archive this group if there are no posts or comments for 90 days
- Don’t automatically archive this group.
- Add a radio buttons to show Group Access:
- Public
- Private
- Unlisted
- Add a checkbox to show Allow Customers option
- Add a checkbox to show Broadcast Only option
- Add a screen to capture the user’s input for new chatter group
- Add a Create Records element to create a new chatter group
- Create a text variable to store existing chatter group Id
- Add a Get Records element to find the members of existing Chatter Group
- Add a Decision element to check if the record collection variable (from step 1.4) is null or not
- Add a loop element to extract records from the record collection variable (from step 1.4)
- Add an Assignment element to Assign the new groupid to the loop variable
- Add an Assignment element to add the Record variable to a Record collection Variable.
- Add a Create Records element to add members to new chatter group
- Add a screen to capture the user’s input.
- Create a Quick Action to launch the flow
- Add quick action to the Group Lightning Record page
Step 1: Salesforce Flow – Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Screen Flow option and click on Next and configure the flow as follows:
- How do you want to start building: Freeform
- It will open the flow designer for you.
Step 1.1: Salesforce Flow – Add a Screen Element
- Under Toolbox, select Elements. Drag and drop Screen onto the canvas.
- Input the following information:
- Enter Label the API Name will auto-populate.
- Click Done.
Step 1.1.1: Salesforce Flow – Add a Text Component to Store Group Name
- Under Input section on Screen Element. Drag and drop the Text component onto the screen.
- Input the following information:
- Enter a name in the Label field; the API Name will auto-populate.
- Select Require checkbox.
- Click Done
Step 1.1.2: Salesforce Flow – Add a Long Text Area Component to Store Description
- Under Input section on Screen Element. Drag and drop the Long Text Area component onto the screen.
- Input the following information:
- Enter a name in the Label field; the API Name will auto-populate.
- Click Done.
Step 1.1.3: Salesforce Flow – Add a Radio Button to Display the Automatic Archiving Options
- Under Input section on Screen Element. Drag and drop the Radio Button component onto the screen.
- Input the following information:
- Enter a name in the Label field; the API Name will auto-populate.
- Data Type: Boolean
- Add First Option
- Click Done
- Add Second Option
Step 1.1.4: Salesforce Flow – Add a Radio Button Component to Display the Group Access Options
- Under Input section on Screen Element. Drag and drop the Radio Button component onto the screen.
- Input the following information:
- Click Done.
Step 1.1.5: Salesforce Flow – Add a Checkbox Component to Show Allow Customers Option
- Under Input section on Screen Element. Drag and drop the Checkbox component onto the screen.
- Input the following information:
- Enter a name in the Label field; the API Name will auto-populate.
- Enter {!$GlobalConstant.False} as Default Value.
- Now we will define the conditions for when the checkbox component is visible.
- When to Display Component: Any Condition Is Met (OR)
- The next step is to define the filter logic if you entered multiple conditions.
- Row 1:
- Resource: Screen Component >> {!Group_Access}
- Operator: Equals
- Value: Private
- Click Done
- Row 2:
- Resource: Screen Component >> {!Group_Access}
- Operator: Equals
- Value: Unlisted
- Click Done
- Row 1:
- Click Done.
Step 1.1.6: Salesforce Flow – Add a Checkbox Component to Show Broadcast Only Option
- Under Input section on Screen Element. Drag and drop the Checkbox component onto the screen.
- Input the following information:
- Enter a name in the Label field; the API Name will auto-populate.
- Enter {!$GlobalConstant.False} as Default Value.
- Click Done.
Step 1.2: Salesforce Flow – Create Records – Create a New Chatter Group
The next step is to create a new chatter group. For this will use the Create Records element.
- Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
- Input the following information:
- Enter Label the API Name will auto-populate.
- How Many Records to Create: One
- How to Set the Record Fields: Use separate resources, and literal values
- Object: CollaborationGroup
- Set Field Values for the User
- Row 1:
- Field: CanHaveGuests
- Value: {!Allow_customers}
- Add Field
- Row 2
- Field: CollaborationType
- Value: {!Group_Access}
- Add Field
- Row 3
- Field: Description
- Value: {!Description}
- Add Field
- Row 4
- Field: IsAutoArchiveDisabled
- Value: {!Automatic_Archiving}
- Add Field
- Row 5
- Field: IsBroadcast
- Value: {!BroadcastOnly}
- Add Field
- Row 6
- Field: Name
- Value: {!Group_Name}
- Row 1:
- Click Done.
Step 1.3: Salesforce Flow – Add a Text Variable to Store Exisitng Chatter Group Id
- Under Toolbox, select Manager, then click New Resource to store existing chatter group Id.
- Input the following information:
- Resource Type: Variable
- API Name: recordId
- Data Type: Text
- Default Value: {!$GlobalConstant.EmptyString}
- Check Available for Input
- Check Available for Output
- Click Done.
Step 1.4: Salesforce Flow – Adding a Get Record Element to Find the Members of Existing Chatter Group
The next step is to use the CollaborationGroupMember object to find the members of an existing chatter group. For this will use the Get Records element.
- Under Toolbox, select Element.
- Drag-and-drop Get Records element onto the Flow designer.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the CollaborationGroupMember object from the dropdown list.
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Row 1:
- Id: CollaborationGroupId
- Operator: Equals
- Value: {!recordId}
- Add Condition
- Row 2
- Id: MemberId
- Operator: Does Not Equals
- Value: {!$User.Id}
- Row 1:
- How Many Records to Store:
- select All records
- How to Store Record Data:
- Choose the option to Automatically store all fields.
- Click Done.
Step 1.5: Salesforce Flow – Using Decision Element to Check the Record Collection Variable (from step 1.4)
Now we will use the Decision element to check the Record Collection Variable from step 1.4 to find if it returns the record or not.
- Under Toolbox, select Element.
- Drag-and-drop Decision element onto the Flow designer.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!Find_Group_Members}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- Click Done.
Step 1.6: Salesforce Flow – Add a Loop Element to Retrieve Records from Record Collection Variable (from step 1.4)
- Drag-and-drop the Loop element onto the Flow designer.
- Enter a name in the Label (For Each) field – the API Name will auto-populate.
- For Collection Variable select {!Find_Group_Members}.
- For Specify Direction for Iterating Over Collection select the option First item to the last item.
- Click Done.
Step 1.7: Salesforce Flow – Adding an Assignment Element to Assign the Newly Created Chatter GroupId to the Loop variable
- Drag-and-drop the Assignment element onto the Flow designer.
- Enter a name in the Label field – the API Name will auto-populate.
- Set Variable Values
- Row 1:
- Field: {!For_Each.CollaborationGroupId}
- Operator: Add
- Value: {!Create_Chatter_Group}
- Row 1:
- Click Done.
Step 1.8: Salesforce Flow – Adding an Assignment Element to Add the Record Variable to Record Collection Variable
- Create a Record Collection Variable varCollaborationGroupMembers type CollaborationGroupMember to store record variable for the bulk process.
- Drag-and-drop the Assignment element onto the Flow designer.
- Enter a name in the Label field – the API Name will auto-populate.
- Set Variable Values
- Row 1:
- Field: {!varCollaborationGroupMembers}
- Operator: Add
- Value: {!For_Each}
- Row 1:
- Click Done.
Step 1.9: Salesforce Flow – Adding a Create Records Element to Add Members to Newly Created Chatter Group
- Under Toolbox, select Element.
- Drag-and-drop the Create Records element onto the Flow designer.
- Enter a name in the Label field- the API Name will auto-populate.
- For How Many Records to Create select Multiple.
- Map Record Collection: {!varCollaborationGroupMembers}
- Click Done.
In the end, Brenda’s Flow will look like the following screenshot (I turned on Auto-Layout) for this flow:
Once everything looks good, perform the steps below:
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- How to Run the Flow: System Context Without Sharing—Access All Data
- Type: Screen Flow
- API Version for Running the Flow: 52
- Interview Label: Clone a Chatter Group {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Step 2: Create a Quick Action to Launch the Flow
The next step is to create a quick action (Clone Chatter Group) on the Group object to launch the Flow. Salesforce will automatically pass the chatter group Id to recordId variable.
- Click Setup.
- In the Object Manager, type Group.
- Select Buttons, Links, and Action, then click New Action.
- Input the following information:
- Select Flow as Action Type.
- Select Clone a Chatter Group as Flow.
- Enter Label (Clone Chatter Group) the Name will auto-populate.
- Click Save.
Step 3: Add Quick Action to Group Lightning Record Page
The next step is to distribute a flow to Lightning Experience or Salesforce app users, by embedding it in the Group Lightning record page.
- Click Setup.
- In the Object Manager, type Group.
- Select Lightning Record Pages, click on the Label to open the page.
- Click on the Edit button to open a Lightning page in the Lightning App Builder.
- From the Highlights Panel
- Click Add Action
- In the Actions modal, choose an action i.e. Clone Chatter Group, as shown in the following screenshot:
- Click Done.
- Once everything looks good, click the Save button.
Proof of Concept
Now Onwards, any users can use this application to clone an existing Chatter group with members.
- To clone a Chatter Group, navigate to the Group tab and click on any Group Name to open its detail page
- Click on the Clone Chatter Group button and perform the steps, as shown in the video:
Formative Assessment:
I want to hear from you!
What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes?
Make a post and tag me on Twitter @automationchamp using #AutomationChampionFlow.
Looking forward to it
Hi there , just had a look through the steps here, my question is this, will this copy across ALL posts and attachments when cloning?.
Thanks
Hi Roberto,
No it will only Clone Chatter Group with all members. If you want to clone Chatter group with members including all posts and attachment then you have to create a new flow for Cloning Posts and attachments.
Wow !!! thanks for such a rapid response! can you advise on how I will do that?
By the way I am going to place an order on your book, looking forward to it.
Basically you have to extract all posts and attachements from CollaborationGroupFeed (http://goo.gl/Gok8MO) object and copy into new groups. I never try this but I know it’s possible. I will try to write a blog post on it. Thanks
Mmm , that looks a bit tricky for my knowledge of Salesforce Im a basic admin here and would love to wait for your blog on how this is done.
It’s quite easy what you have to do is drag and drop Fast lookup onto canvas. Set condition according to your need like (NetworkScope = “Old Chatte Group ID” and Type =”TextPost”) and store value in Sobject collection, Now you have to apply logic to create post on new group. Wait few days I will post my article