InSalesforce Chatter is a great way to boostcollaborationin your organization. A user can Post Status, Links, Files, and comments on others post. Many time I found on discussion board people are looking for a way toDelete System generated Chatter post. In this article, I am going to discuss how to auto-delete system generatedChatter post. Let’s start with a business use case

Business Use case

Warren Mason is working as System administrator at Universal Containers (UC). When we convert the Lead automatic chatter post appears on Account feed i.e. UserName converted a lead to this account, as shown in the following screenshot

Auto generated chatter post

He wants to auto delete this post upon lead conversion.

Solution for the above business requirement

There are few solutions possible for the above business scenario. We will use Flow and Process Builder to solve the above business requirement. Before proceeding you have to understand the Feed table in Salesforce. All objects have a default related “Feed” object. All Feed objects for custom objects are named as CustomObject__Feed, where CustomObject__c is the name of the related custom object. All Feed objects for standard objects are named as LeadFeed, where Lead is the name of the related standard object. Now you have to understand below-mentioned objects in Salesforce

A) AccountFeed: – This object represents a single feed item in the feed displayed on the detail page for a lead record.

First of all, we will useFlow to delete system generated Chatter post. To launch the Flow whenever Lead getsconverted we will useProcess Builder. This article will help you to understand how to auto-delete system generated chatter post by using Flow and Process Builder. Follow the below instructions to create a Flow for the above business requirement

1. First of all, create few fields as Shown in the following table

Field Name

Object

Data Type

Default Value

Lead Conversion

Account

Checkbox

Unchecked

Lead Conversion

Lead

Checkbox

Checked

We will use above fields in the Process Criteria.

2. Click on Setup | Build | Customize | Leads | Fields, navigate to Lead Custom Fields & Relationships related list and click on the Map Lead Fields button. It will redirect you to another page where you can map each of your organization’s lead custom fields to one of your custom account, contact, or opportunity fields. These mappings will be used when you convert leads. Map both the fields as shown in the following screenshot

Map Lead Fields

3. Click on Setup | Build | Create | Workflows & Approvals | Flows4. Click on New Flow, it will open the Flow Canvas for you. Create two text variables VarT_ParentId (To pass account Id) as Shown in the following screenshot

Text Variable

5. The next step is to delete system generated post upon lead conversion. For this drag-and-drop Record Delete Element (Give the nameDelete lead conversion Chatter post) on the Flow Canvas and fill the details as shown in the following screenshot

Delete Record – delete system generated chatter post

Once you are done click onOK. Finally, yourFlowwill look like the following screenshot, click on icon that mark in red to set asstartpoint

6. Save your flow with nameDelete system generated post and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a Process onAccount object to launch a Flow. To create a Process on theAccount object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder and click on the New button, Enter Name, API Name and click on the Save button2. Click onAdd Object, selectAccount object and for the entry criteria, Select when a record is created, as shown in the below screenshot and also click on theSave button

Evaluation Criteria

3. The next task is to add ProcessCriteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions (In this case set [Account].Lead_Conversion__c Equals True) and click on theSave button, as shown in the following screenshot

Process Criteria

4.The next task is to set the time for schedule action. For this click on Set Schedule available under Scheduled actions. Set time for scheduled actions as shown in the following screenshot

Time for Scheduled action

5. Now we have to add a Time-based action into the Process to Launch a Flow. For this, we will use Flow action, Use Field Picker to select the field AcountID. Please refer to the following screenshot for more details

Add action – Flows

6. Once you are done, click on theSavebutton, it will redirect you to Process canvas. Finally, theProcesswill look like the following screenshot

Don’t forget to active the Process by clicking on theActivatebutton

It’s time to test this App

Now onwards if a business user converts a lead, then Process Builder will automatically trigger and Launch the Flow then it will delete the system generated post after a few minutes.

1. Below is the current status of lead “Ms. Kristen Akin” before conversion, as shown in the following screenshot

Lead status before conversion

2. The next step is to convert the link. After successful conversion, you will redirect to account detail page, as shown in the following screenshot

Account detail page

3. Wait a few minutes and refresh the account detail page and check out the account feed

Final Output

Note: – I will suggest you to implement this first on your developer org test it and then move it to Production.

chris markiewicz

Thanks for this. I implemented it and it works as described, however as an earlier comment notes, there is potentially some collateral damage. When I was testing, it would typically take around one minute for the AccountFeed record to be deleted. If, in that window, I added other Chatter Posts to the Account, they would also be deleted (undesirable behavior). My fix to this: change the Flow so that it first does a RecordLookup – where you lookup the AccountFeed record, sorting by CreatedDate – it will only grab the first AccountFeed record, which should be the offending post. Then you can delete it.
Thanks again for posting this.
chris

Thanks for this info. Would you have any suggestions on how to modify this for another process? I need to auto delete all system generated feeds on cases. I am getting a flow error that says Error Occurred: No records in Salesforce match your delete criteria.

Rakesh Gupta

1. First, put a Record lookup element (Criteria is same as Record Delete element) to query Chatter feed
2. Then use Decision element to verify the outcome of Record Lookup element to make sure that there is something to delete.
3. In case, if there are Chatter feed then use Record Delete element to delete Chatter Feeds

Yes, it is possible to post birthday messages to a Chatter group. Before that, you have to save Date of Birth in a field. Then use a formula field to calculate birthday in the current year, and then use Process builder with time-based actions.