Automatically Add a Record to Chatter Group

Automatically Add a Record to Chatter Group

Last Updated on May 19, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do you automatically add a record to the Chatter Group?

Salesforce allows you to add a record to Chatter Groups, which means you can now collaborate and discuss the records as a team in the group. You can only add Account, Contact, Contract, Campaign, Case, Lead, Opportunityand Custom object records to chatter groups. 


After reading this article, the reader will be able to:

  • Use After-save Record-Triggered Flow to add the newly created opportunities to chatter Group
  • How to refer custom label in After-save Record-Triggered Flow
  • Use a Decision element to find – record variable or record collection variable contains a record or not

Business Use case

Steven Greene is working as a System Administrator at Universal Containers (UC). He has received a new requirement from the management, whenever an Opportunity is created or updated with an amount greater than $ 100,000, then automatically it to Chatter Group (UC Internal Announcements).

Automation Champion Approach (I-do):

There are a few possible solutions for the above business scenario, but I’ll use After-save Record-Triggered Flow to solve the business requirement. 

Let’s take a pause here, familiar yourself with the CollaborationGroupRecord Object in Salesforce. It represents the records associated with Chatter groups.

Field Name Details
RecordId It represents the Id of the record associated with Chatter Group.
CollaborationGroupId The ID of the Chatter group.

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 4 steps to solve Steven’s business requirement using Salesforce Flow. We must:

  1. Create a chatter group
  2. Find the chatter group Id
  3. Creating a custom label to store chatter group Id
  4. Salesforce Flow Steps:
    1. Define flow properties for record-triggered flow and check the amount 
    2. Add a get record element to find collaboration group record Id for the current opportunity 
    3. Add a decision element to check the collaboration group id from the record variable (from step 4.2)
    4. Add a create records element to add opportunity record to chatter group 

Step 1: Create a Chatter Group

  1. Navigate to App Launcher and click on the Groups.
  2. Clicks on the New button. 
  3. Name the Group and make sure to select the Private Access Type.
  4. Click Save.

Step 2: Find the Chatter Group Id for UC Internal Announcements 

The next step is to find out the Id of the chatter group UC Internal Announcements. One possible workaround is to use the Developer Console. 

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. Select id, name from collaborationgroup where (name=’UC Internal Announcements’)
  3. Make sure to copy the Id. 

Step 3: Creating a Custom Label to Store Chatter Group Id

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the UC Internal Announcement chatter group id in the Value.
  6. Click Save.

Step 4.1: Salesforce Flow – Define Flow Properties 

As we have a requirement of creating a record in (CollaborationGroupRecord), this is why we have to use After Save flow. 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created or updated
    3. Run Flow: After the record is saved
    4. Object: Opportunity
  5. Select All Condition Are Met (AND)
  6. Set Conditions
    1. Row 1
      1. Field: Opportunity | Amount
      2. Operator: Greater Than
      3. Value: 100000
  7. Select Only when a record is updated to meet the condition requirements.
  8. Click Done.

Step 4.2: Salesforce Flow – Adding a Get Record Element to Find Collaboration Group Record Id For the Current Opportunity

The next step is to find the Collaboration Group Record Id For the current opportunity, to make sure that – opportunity is not already added to the group. To do that follow the below instructions:

  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 Record CollaborationGroupRecord object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: CollaborationGroupId
      2. Operator: Equals
      3. Value: {!$Label.UC_Internal_Chatter_Group_ID}
    2. Add Condition
    3. Row 2:
      1. Field: RecordId
      2. Operator: Equals
      3. Value: {!$Record.Id}
  7. How Many Records to Store:
    1. select Only the first record
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

Step 4.3: Salesforce Flow – Using Decision Element to Check the Record Id from the Record Variable (from step 4.2)

Now we will use the Decision element to check the Record Variable from step 4.2 to find if it returns the record id 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_Collaboration_Group_Record_Id.Id}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.True}
  6. Click Done.

Step 4.4: Salesforce Flow – Create Records – Add Opportunity Record to Chatter Group

The next step is to add an opportunity record to the chatter group. We 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: CollaborationGroupRecord
    5. Set Field Values for the Group Record
    6. Row 1:
      1. Row 1:
        1. Field: CollaborationGroupId
        2. Value: {!$Label.UC_Internal_Chatter_Group_ID}
      2. Add Field
      3. Row 2
        1. Field: RecordId
        2. Value: {!$Record.Id}
  3. Click Done.

In the end, Steven’s Flow will look like the following screenshot:

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. Type: Record-Triggered Flow
  5. API Version for Running the Flow: 50
  6. Interview Label: Add Permission Set to New Users {!$Flow.CurrentDateTime}
  7. Click Save

Almost there! Once everything looks good, click the Activate button.

Proof of Concept

Now onwards if a business user updates the Opportunity Stage to Closed Won, Salesforce Flow will automatically add the record from Chatter Groups.

  1. Below is the current amount of Opportunity West Mountain Sign | Q1 2021 is 1,200 USD Status before. Currently, the opportunity is not shared with any  Chatter groups.
  2. Update the Amount to $1.1 M
  3. Once you are done, click on the Save button.
  4. Now check the Group related list on the Opportunity object. Record is already added to chatter group UC Internal Announcements, as shown in the following screenshot:

Formative Assessment:

I want to hear from you!  

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

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

14 thoughts on “Automatically Add a Record to Chatter Group

    1. When opportunity add products that amount reflected to contract object amount field , using flow + process builder,how to do this please give suggestion on this any one.(urgent)

Leave a Reply

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