Is Your Chatter Group Data Clean? No? Use Flow to Do So!

Is Your Chatter Group Data Clean? No? Use Flow to Do So!

Last Updated on February 10, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do you provide a way for deleting the Chatter group feed to the key 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 the Chatter group is very cluttered that as a manager, you want to delete the old post. There are a few apps available on AppExchange for this purpose, but nothing comes out-of-the-box. In this article, we will create automation that allows users to delete a specific type of posts for Chatter groups.


This blog post will help us to understand the following

  • Use a Screen a flow to take the user input 
  • How to delete the records using the delete records element 
  • Understand how to create a custom permission
  • Understand how to use custom permission to hide a component 

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 a set of users to delete posts (created before a specific date) from Chatter groups. 

Automation Champion Approach (I-do):

While this can be solved using various tools:
  1. Manual Deletion
  2. Lightning Web Component 
  3. Apex Code
  4. Data Loader

We will use Salesforce Flow to solve it. 

Before proceeding, ahead, understanding CollaborationGroupFeed objects in Salesforce. It represents a single feed item on a Chatter group feed.
Field Name Details
ParentId The Id of a chatter post. 
LastModifiedId It is the date and time when a record was last modified by a User.

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 Brenda’s business requirement using Screen Flow. We must:

  1. Salesforce Flow Steps: (Screen Flow)
    1. Create a text variable to store chatter group id
    2. Add a screen to capture the user data
      1. Add a screen component
      2. Add a Date component 
    3. Add a get record element to find collaboration group feeds created before a given date
    4. Add a decision element to check the record collection variable (from step 1.3)
    5. Add a delete records element to delete chatter posts
  2. Creating a custom permission
  3. Assign custom permission to the system administrator profile  
  4. Add flow to the chatter group page and add filter criteria 

Step 1.1: Salesforce Flow – Create a Text Variable to Store Chatter Group Id

The Screen flow which we are creating will be used in the Chatter group Page to delete posts. 

  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. Under Toolbox, select Manager. Click on the New Resource
  6. Input the following information:
    1. Resource Type: Variable
    2. API Name: varTCollaborationGroupId
    3. Data Type: Text
    4. Default Value: {!$GlobalConstant.EmptyString}
    5. Check Available for Input
    6. Check Available for Output
  7. Click Done

Step 1.2.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.2.2: Add a Date Component to Allow Users the Enter Date to Delete Past Chater Posts 

  1. Under Input section on Screen Element. Drag and drop Date onto the screen. 
  2. Input the following information:
    1. Enter API Name.
    2. Label: Enter Date
    3. The API Name will auto-populate
    4. Require: True 
  3. Click Done.

Step 1.3: Salesforce Flow – Adding a Get Record Element to Find Collaboration Group Feeds Created Before a Given Date

  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 CollaborationGroupFeed object from the dropdown list.
  5. Select All Conditions Are Met (AND).
  6. Set Filter Conditions
    1. Row 1:
      1. Field: ParentId
      2. Operator: Equals
      3. Value: {!varTCollaborationGroupId}
    2. Click Add Condition
    3. Row 2:
      1. Field: LastModifiedDate
      2. Operator: Less Than or Equal
      3. Value: {!Enter_Date}
  7. How Many Records to Store:
    1. select All record
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

Step 1.4: Salesforce Flow – Using Decision Element to Check the Record Collection Variable (from step 1.3)

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

Step 1.5: Salesforce Flow – Delete Records – Delete Chatter Group Posts

The next step is to add a logged-In user 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 the IDs stored in a record variable or record collection variable
    4. Select Record(s) to Delete
      1. Record or Record Collection: {!Find_Feeds}
  3. Click Done.

In the end, Brenda’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: Screen Flow
  5. API Version for Running the Flow: 51
  6. Interview Label: Clean Chatter Group {!$Flow.CurrentDateTime}
  7. Click Save

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

Step 2: Creating a Custom Permission 

By using custom permissions, you can grant users access to custom apps. In Salesforce, you can use custom permissions to check which users can access certain functionality. Custom permissions let you define access checks that can be assigned to users via permission sets or profiles – similar to how you assign user permissions and other access settings. You can even use custom permission to bypass the validation rule for certain users or profiles. Let us create custom permission to hide the flow component. 

  1. Click Setup.
  2. In the User Interface, type Custom Permissions.
  3. Click on the New button.
  4. Enter Label the Name will auto-populate. 
  5. Click Save.

Step 3: Assign Custom Permission to the System Administrator Profile 

  1. Click Setup.
  2. In the User Interface, type Profiles.
  3. Open the System Administrator profile. 
  4. Then navigate to Apps | Custom Permission and click on the Edit button.
  5. Now, assign the Clean Group Posts custom permission to the profile.
  6. Click Save.

Step 4: Add a Flow to Lightning Page and Add Filter Criteria 

The next step is to distribute a flow to Lightning Experience or Salesforce app users, by embedding it in a Lightning page.

  1. Navigate to App Launcher and click on the Groups.
  2. Open any Chatter Group and Edit the page.
  3. From the Lightning Components pane on the left, drag the Flow component onto the Lightning page canvas.
  4. Input the following information:
    1. Select Clean Chatter group flow
    2. for varTCollaborationGroupId
      1. Select Pass record ID into this variable checkbox
    3. Click + Add Filter
    4. Set Filter Conditions
    5. Row 1:
      1. Field: Permission > Custom Permission > Clean_Group_Posts 
      2. Operator: Equal
      3. Value: True
  5. Click Done.

Once everything looks good, click the Save button. 

Proof of Concept

    1. As of now UC Internal Announcements – Chatter Group has three posts that were created before November 19, 2020.
    2. Now let’s delete the chatter created on or before November 18, 2020.
    3. BOOM now checks UC Internal Announcements – Chatter Group Feed, are chatter posts created on or before November 18, 2020, were deleted.

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!

6 thoughts on “Is Your Chatter Group Data Clean? No? Use Flow to Do So!

  1. When I was looking for Group feed in the Object Search, it is not showing anything. How do one came to know that Group Feed is an Object and is there in our org?

  2. Hi Rakesh,
    Your blog is very ice, I read it quite often, thank you.
    I have a questions:
    On a Community, I want to prevent my Partner User from writing any Chatter post on any Account Feed.
    Do you think of any way to do this ?
    Do you think it would be possible to create a flow that deletes Chatter Posts created by Partner User on ACCOUNT object
    Thank you for your cooperation.
    Best Regards,

Leave a Reply

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