In Salesforce Chatter is a great way to boost collaboration in 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 to Delete System generated Chatter post. In this article, I am going to discuss how to auto-delete system generated Chatter 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
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 use Flow to delete system generated Chatter post. To launch the Flow whenever Lead gets converted we will use Process 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
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
3. Click on Setup | Build | Create | Workflows & Approvals | Flows
4. 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
5. The next step is to delete system generated post upon lead conversion. For this drag-and-drop Record Delete Element (Give the name Delete lead conversion Chatter post) on the Flow Canvas and fill the details as shown in the following screenshot
Once you are done click on OK. Finally, your Flow will look like the following screenshot, click on icon that mark in red to set as start point
6. Save your flow with name Delete 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 on Account object to launch a Flow. To create a Process on the Account 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 button
2. Click on Add Object, select Account object and for the entry criteria, Select when a record is created, as shown in the below screenshot and also click on the Save button
3. The next task is to add Process Criteria, 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 the Save button, as shown in the following screenshot
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
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
6. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot
Don’t forget to active the Process by clicking on the Activate button
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
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
3. Wait a few minutes and refresh the account detail page and check out the account feed
Note: – I will suggest you to implement this first on your developer org test it and then move it to Production.