Delete Complete Chatter Conversation Using Salesforce Flow

Delete Complete Chatter Conversation Using Salesforce Flow

Last Updated on June 22, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How can users be allowed to delete Chatter conversation?

This is a continuation of my previous article Delete Chatter Messages Using Salesforce Flow, In that I had discussed a way which allows your users to delete Chatter messages. This article goes a step ahead and explains, how to delete all messages at once, i.e. how to delete a Chatter conversation. Chatter conversation is nothing but messages that members have sent or received. 


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

  • Use automation to increase user permissions
  • Create a custom object to store the Id of a Chatter conversation
  • Use Record-Triggered Flow to delete the Chatter Conversation 

Business Use case

Rachel Gillett is working as a System administrator at Universal Containers (UC). She has received a requirement from management to allow their Sales reps (License Type: – Salesforce Platform) to delete Chatter conversation from Salesforce UI.

Automation Champion Approach (I-do):

**Chatter Messages functionality is only available in Classic

First, it is important to understand Chatter messages and Chatter Conversations in Salesforce. Chatter messages let you have secure private conversations with other Chatter users. Use messages to send your colleague a question privately or to communicate with a few selected people when a discussion isnt relevant to everyone you work with. A Chatter conversation consists of messages that conversation members have sent or received.  

Remember the following points for using Chatter messages

  1. A private message can include up to 9 members, including yourself.
  2. Messages sent will not be viewable through Chatter feed, Chatter Profile, or Global Search results.
  3. You can’t delete messages or conversations.
  4. An administrator with the Manage Chatter Messages permission can view and delete all users messages in ChatterThis may be necessary for compliance purposes
    1. Messages are hard deleted. They aren’t sent to the Recycle Bin.
    2. Deleted messages aren’t included in message search results.
    3. If all messages in a conversation are deleted, the conversation doesnt show in My Messages and cant be retrieved via the Chatter REST API.
  5. If after reading the messages in a conversation you want to mark the conversation unread, you can do so only via the Chatter REST API, not via the user interface.

There are a few possible solutions for the above business scenario, but I’ll use Salesforce Flow and Custom Object to solve the business requirement. As discussed earlier, a System Administrator with the Manage Chatter Messages permission can view and delete all users’ messages in Chatter. Business users are not allowed to delete messages or conversations.

In Salesforce the ChatterMessage object represents a message sent as part of a private conversation in Chatter. There are some relevant fields to identify:

Field Name Details
Id Chatter Message Id
ConversationId The ID of the conversation that the ChatterMessage is associated with.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understanding it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Rachel’s business requirement using Record-triggered Flow. We must:

  1. Grant manage chatter permission 
  2. Create a custom object with few fields that will be used to save the Id of the Chatter conversation, which the users want to delete
  3. Salesforce Flow Steps:
    1. Define flow properties for record-triggered flow
    2. Add a decision element to check Chatter Conversation Id field is not null
    3. Add a Delete Records element to delete the Chatter Conversation

Step 1: Grant Manage Chatter Messages Permission to Users

First, create a Permission Set to grant your user record Manage Chatter Messages permission. Otherwise, you will get an error while building the Flow. The permission can be removed later.

Step 2: Create a Custom Object – Delete Chatter Conversation 

Create a custom object (Delete Chatter Conversation) and a text field to save the Chatter Conversation Id.

  1. Click Setup.
  2. In the Object Manager, click Create | Custom Object.
  3. Now create a custom object Delete Chatter Conversation and fields as shown in the screenshot below: 
  4. Click Save.

Make sure that you have marked the field Chatter_Conversation_Id__c as required and also granted CRUD access to the respective profiles.

Step 3.1: Define Flow Properties

The next step is to create a Flow to implement the business requirement, i.e. delete chatter conversation when someone created a record in the custom object created in step #2.

  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, click on Create and configure the flow as follows:
    1. Object: Delete Chatter Conversation
    2. Trigger the Flow When: A record is created
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 3.2: Using Decision Element to Check If Chatter Conversation Id Field is Populated or Not

The next step is to check the chatter conversation-id field is populated or not. To check this, we will use the Decision element.

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!$Record.Chatter_conversation_Id__c}
      2. Operator: Is Null
      3. Value: {!$GlobalConstant.False}
  5. Click Done.

Step 3.3: Add Action – Delete Record

The next step is to delete the chatter conversation. For this, we will use the Delete Records element.

  1. On Flow Designer, below the Yes node, click on the +icon and select the Delete Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. For How to Find Records to Delete select Specify conditions.
  4. Select the ChatterMessage object from the dropdown list.
  5. Set Filter Conditions
    1. Row 1:
      1. Field: ConversationId
      2. Operator: Equals
      3. Value: {!$Record.Chatter_Conversation_Id__c}
  6. Click Done.

In the end, Rachel’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. API Version for Running the Flow: 55
  5. Interview Label: Delete Chatter Conversation {!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

  1. Logged in as Platform User Brenda David (Custom Platform profile).Salesforce Platform User
    1. No extra permission is assigned to this user apart from Create and Read permission on the Delete Chatter Conversation object.
  2. Brenda wants to delete a Chatter conversations (all messages in a thread) sent by Sales User Rakesh Gupta, but as a business user when she can’t run a query to get the IdChatter Conversation
  3. To get a Chatter Conversation Id, open the chatter message and right-click on it, and then select Inspect Element, as shown in the following screenshot:Select Inspect Element for a Chatter Conversation
  4. A window will open at the bottom of the current screen. Find and copy the Chatter Conversation Id as shown in the following screenshot:Chatter Conversation Id
  5. Create a new record in the Delete Chatter Conversation object, as shown in the following screenshotCreate a new record
  6. Navigate to the Chatter messages and check it out now. The conversation (i.e. test2w333?) sent by System Administrator Rakesh Gupta gets deleted.

Final Output

Note: – You are only able to delete those Chatter conversations in which you are included, otherwise you will get an error. (There is nothing in Salesforce matching your delete criteria). It’s not applicable to the system administrator with the Manage Chatter Messages permission.

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? Feel free to share in the comments below.

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)

Leave a Reply

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