Getting Started with Salesforce Flow – Part 59 (Clone a Chatter Group with Members)

Getting Started with Salesforce Flow – Part 59 (Clone a Chatter Group with Members)

Last Updated on July 23, 2021 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?! 

  1. Getting Started with Salesforce Flow – Part 26 (Automatically Add a Record to Chatter Group)
  2. Getting Started with Salesforce Flow – Part 34 (Post Opportunity Details to a Chatter Group)
  3. Getting Started with Salesforce Flow – Part 46 (Is Your Chatter Group Data Clean? No? Use Flow to Do So!)
  4. Getting Started with Process Builder – Part 18 (Auto Creates a Private Chatter Group )
  5. Getting Started with Process Builder – Part 24 (Automatically Add User to Chatter Group)
  6. Getting Started with Process Builder – Part 82 (Recipes for Automating Chatter Group Management)
  7. 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):

While this can be solved using various tools:
  1. Lightning Web Component 
  2. Apex Code
  3. Data Loader
  4. 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:

  • D—Daily
  • W—Weekly
  • N—Never
  • P—On every post

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:

  1. Salesforce Flow Steps: Define flow properties
    1. Add a screen to capture the user’s input.
      1. Add a screen to capture the user’s input for new chatter group 
        1. Group Name
        2. Description
        3. 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.
        4. Add a radio buttons to show Group Access:
          1. Public
          2. Private
          3. Unlisted
        5. Add a checkbox to show Allow Customers option
        6. Add a checkbox to show Broadcast Only option
    2. Add a Create Records element to create a new chatter group
    3. Create a text variable to store existing chatter group Id
    4. Add a Get Records element to find the members of existing Chatter Group
    5. Add a Decision element to check if the record collection variable (from step 1.4) is null or not
    6. Add a loop element to extract records from the record collection variable (from step 1.4) 
    7. Add an Assignment element to Assign the new groupid to the loop variable 
    8. Add an Assignment element to add the Record variable to a Record collection Variable.
    9. Add a Create Records element to add members to new chatter group
  2. Create a Quick Action to launch the flow
  3. Add quick action to the Group Lightning Record page

Step 1: Salesforce Flow – Define Flow Properties   

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Screen Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. It will open the flow designer for you.

Step 1.1: Salesforce Flow – Add a Screen Element  

  1. Under Toolbox, select Elements. Drag and drop Screen onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
  3. Click Done

Step 1.1.1: Salesforce Flow – Add a Text Component to Store Group Name

  1. Under Input section on Screen Element. Drag and drop the Text component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
    2. Select Require checkbox.
  3. Click Done

Step 1.1.2: Salesforce Flow – Add a Long Text Area Component to Store Description

  1. Under Input section on Screen Element. Drag and drop the Long Text Area component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
  3. Click Done.

Step 1.1.3: Salesforce Flow – Add a Radio Button to Display the Automatic Archiving Options 

  1. Under Input section on Screen Element. Drag and drop the Radio Button component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
    2. Data Type: Boolean
    3. Add First Option
      1. Under Select Choices 
        1. Click + New Resource; it will open a pop-up for you
        2. Resource Type: Choice
        3. API Name: AutoArchive
        4. Choice Label: Archive this group if there are no posts or comments for 90 days
        5. Data Type: Boolean
        6. Choice Value: {!$GlobalConstant.False}
    4. Click Done
    5. Add Second Option
      1. Under Select Choices 
        1. Click + New Resource; it will open a pop-up for you
        2. Resource Type: Choice
        3. API Name: ManualArchive
        4. Choice Label: Don’t automatically archive this group
        5. Data Type: Boolean
        6. Choice Value: {!$GlobalConstant.True}
      2. Click Done.

Step 1.1.4: Salesforce Flow – Add a Radio Button Component to Display the Group Access Options 

  1. Under Input section on Screen Element. Drag and drop the Radio Button component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
    2. Data Type: Text
    3. Under Select Choices 
      1. Click + New Resource; it will open a pop-up for you
      2. API Name: GroupAccess
      3. Object: Group
      4. Data Type: Picklist
      5. Field: CollaborationType
  3. Click Done.

Step 1.1.5: Salesforce Flow – Add a Checkbox Component to Show Allow Customers Option 

  1. Under Input section on Screen Element. Drag and drop the Checkbox component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
    2. Enter {!$GlobalConstant.False} as Default Value
    3. Now we will define the conditions for when the checkbox component is visible.
      1. When to Display ComponentAny Condition Is Met (OR)
    4. The next step is to define the filter logic if you entered multiple conditions.
      1. Row 1: 
        1. ResourceScreen Component >> {!Group_Access}
        2. OperatorEquals
        3. Value: Private
        4. Click Done
      2. Row 2: 
        1. ResourceScreen Component >> {!Group_Access}
        2. OperatorEquals
        3. Value: Unlisted
        4. Click Done
  3. Click Done.

Step 1.1.6: Salesforce Flow – Add a Checkbox Component to Show Broadcast Only Option 

  1. Under Input section on Screen Element. Drag and drop the Checkbox component onto the screen. 
  2. Input the following information:
    1. Enter a name in the Label field; the API Name will auto-populate.
    2. Enter {!$GlobalConstant.False} as Default Value
  3. 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. 

  1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: CollaborationGroup 
    5. Set Field Values for the User
      1. Row 1:
        1. Field: CanHaveGuests
        2. Value: {!Allow_customers}
      2. Add Field
      3. Row 2
        1. Field: CollaborationType
        2. Value: {!Group_Access}
      4. Add Field
      5. Row 3
        1. Field: Description
        2. Value: {!Description}
      6. Add Field
      7. Row 4
        1. Field: IsAutoArchiveDisabled
        2. Value: {!Automatic_Archiving}
      8. Add Field
      9. Row 5
        1. Field: IsBroadcast
        2. Value: {!BroadcastOnly}
      10. Add Field
      11. Row 6
        1. Field: Name
        2. Value: {!Group_Name}
  3. Click Done.

Step 1.3: Salesforce Flow – Add a Text Variable to Store Exisitng Chatter Group Id

  1. Under Toolbox, select Manager, then click New Resource to store existing chatter group Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: recordId
    3. Data Type: Text
    4. Default Value: {!$GlobalConstant.EmptyString}
    5. Check Available for Input
    6. Check Available for Output
  3. 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. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Get Records element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Select the CollaborationGroupMember object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Id: CollaborationGroupId
      2. Operator: Equals
      3. Value: {!recordId}
    2. Add Condition 
    3. Row 2
      1. Id: MemberId
      2. Operator: Does Not Equals
      3. Value: {!$User.Id}
  7. How Many Records to Store:
    1. select All records
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. 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. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Decision element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Under Outcome Details, enter the Label the API Name will auto-populate.
  5. Condition Requirements to Execute OutcomeAll Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!Find_Group_Members}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.False}
  6. Click Done.

Step 1.6: Salesforce Flow –  Add a Loop Element to Retrieve Records from Record Collection Variable (from step 1.4) 

  1. Drag-and-drop the Loop element onto the Flow designer. 
  2. Enter a name in the Label (For Each) field – the API Name will auto-populate.
  3. For Collection Variable select {!Find_Group_Members}.
  4. For Specify Direction for Iterating Over Collection select the option First item to the last item.
  5. Click Done.

Step 1.7: Salesforce Flow – Adding an Assignment Element to Assign the Newly Created Chatter GroupId to the Loop variable 

  1. Drag-and-drop the Assignment element onto the Flow designer. 
  2. Enter a name in the Label field – the API Name will auto-populate.
  3. Set Variable Values
    1. Row 1:
      1. Field: {!For_Each.CollaborationGroupId}
      2. Operator: Add
      3. Value: {!Create_Chatter_Group}
  4. Click Done.

Step 1.8: Salesforce Flow – Adding an Assignment Element to Add the Record Variable to Record Collection Variable

  1. Create a Record Collection Variable varCollaborationGroupMembers type CollaborationGroupMember to store record variable for the bulk process.
  2. Drag-and-drop the Assignment element onto the Flow designer. 
  3. Enter a name in the Label field – the API Name will auto-populate.
  4. Set Variable Values
    1. Row 1:
      1. Field: {!varCollaborationGroupMembers}
      2. Operator: Add
      3. Value: {!For_Each}
  5. Click Done.

Step 1.9: Salesforce Flow – Adding a Create Records Element to Add Members to Newly Created Chatter Group 

  1. Under Toolbox, select Element
  2. Drag-and-drop the Create Records element onto the Flow designer. 
  3. Enter a name in the Label field- the API Name will auto-populate.
  4. For How Many Records to Create select Multiple.
  5. Map Record Collection: {!varCollaborationGroupMembers}
  6. 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: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. How to Run the Flow: System Context Without Sharing—Access All Data
  5. Type: Screen Flow
  6. API Version for Running the Flow: 52
  7. Interview Label: Clone a Chatter Group {!$Flow.CurrentDateTime}
  8. 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. 

  1. Click Setup.
  2. In the Object Manager, type Group.
  3. Select Buttons, Links, and Action, then click New Action.
  4. Input the following information:
    1. Select Flow as Action Type.
    2. Select Clone a Chatter Group as Flow.
    3. Enter Label (Clone Chatter Group) the Name will auto-populate.
  5. 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.

  1. Click Setup.
  2. In the Object Manager, type Group.
  3. Select Lightning Record Pages, click on the Label to open the page.
  4. Click on the Edit button to open a Lightning page in the Lightning App Builder.
  5. From the Highlights Panel
    1. Click Add Action
    2. In the Actions modal, choose an action i.e. Clone Chatter Group, as shown in the following screenshot:
  6. Click Done.
  7. 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.  

  1. To clone a Chatter Group, navigate to the Group tab and click on any Group Name to open its detail page
  2. 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.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

8 thoughts on “Getting Started with Salesforce Flow – Part 59 (Clone a Chatter Group with Members)

  1. 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

    1. 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.

      1. 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.

          1. 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.

            1. 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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.