Posted at 3:45 PM by Rakesh Gupta, on July 10, 2015
Big Idea or Enduring Question:
How do you automatically delete posts generated from quick actions?
A few months back, I had written an article Getting Started with Process Builder – Part 17 (Auto Delete System Generated Chatter Post) to discuss a way through which, we can auto-delete system generatedChatter posts. This article goes a step ahead and explains, how to auto-delete posts generated from Quick Actions for objects in which Feed Tracking is not enabled.
Objectives:
After reading this article, the reader will be able to:
Using Process Builder to auto-delete system-generated chatter posts
How to use get the delete element to delete records
How to Launch a Flow from Process Builder
Business Use case
Rachel Gillett is working as a System administrator at Universal Containers (UC). At UC they have created a custom object called Time Sheet, to allow their sales reps to enter the time they spent at a customer site (i.e. against Account object). The Time Sheet object has a lookup relationship with the Account object, and Feed tracking is turned off for the Time Sheet object. Rachel has received a requirement from the management when sales reps create a Time Sheet from an account object using quick action, the system auto-generates a chatter post similar to the following screenshot:
Business wants to auto-delete posts generated from Quick Action.
Automation Champion Approach (I-do):
First of all, you have to understand the Feedobject in Salesforce. All objects have a default related Feedobject. 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 Leadis the related standard object name.
But the glitchis Feed object is by default available (You can access it from the API or Flow) for a standard object, even though Feed Tracking is turned off, but that is not the case with the custom object. If Feed tracking is turned off for a custom object, then the CustomObject__Feed object will not be available. So you can’t use the CustomObject__Feed object to delete the posts (On parent object) generated from Quick Actions.
There are a few possible solutions for the above business scenario, but I’ll use Process Builder and Flow to solve the business requirement.
Before discussing it, 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 Rachel’s business requirement using Flow and Process Builder. We must: Read the rest of this entry!
Posted at 2:22 AM by Rakesh Gupta, on April 9, 2015
Big Idea or Enduring Question:
How do you delete system generated Chatter posts?
Objectives:
After reading this blog post, the reader will be able to:
Create an Auto-Launched flow to delete records
Launch a Flow using Process Builder to auto-delete Chatter Posts
Business Use case
Warren Mason is working as a System Administrator at Universal Containers (UC). When we convert the Lead, an automatic chatter post appears on the 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.
Automation Champion Approach (I-do):
Salesforce Chatter is a great way to boost collaboration in your organization. A user can post statuses, links, and files and comment on other’s posts. However, many times I have found that people are looking for ways to delete system generated Chatter posts.
In this article, I am going to discuss how to auto-delete system generated Chatter posts. There are several possible solutions. I will help you understand how to auto-delete system generated Chatter posts using Flow, and we will launch the Flow via Process Builder when the Leads gets converted.
Before proceeding, you have to understand the Feed table in Salesforce. All objects have a default related “Feed” object.
For custom objects, all feeds are named as CustomObject__Feed, where CustomObject__c is the name of the related custom object, such as JobApplication_Feed.
For standard objects, all feeds are named as ObjectFeed, where Object is the name of the related standard object, such as LeadFeed.
Now you have to understand the below-mentioned object in Salesforce:
AccountFeed: – This object represents a single feed item in the feed displayed on the detail page for a Lead record.
Before discussing it, 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 5 steps to solve Warren’s business requirement using Flow and Process Builder. We must:
Create a custom checkbox field on Lead
Create a custom checkbox field on Account
Map custom lead fields for lead conversion
Lightning Flow Steps:
Define flow properties for auto-launched flow
Add a text variable to store account id
Add a delete records element to delete system generated post
Process Builder Steps:
Define process properties
Define evaluation criteria
Define process criteria
Set time for actions to execute
Add action – flows
Step 1: Creating a Checkbox Field on Lead Object
Click Setup.
In the Object Manager, type Lead.
Select Fields & Relationships, then click New.
Select Checkbox as Data Type, then click Next.
Enter Field Label and click the tab key, the API Name will populate.
As a best practice, always input a description.
Default Values: Checked
Set the Field-level Security for the profiles, make sure to set this field as read-only.
Do not add this field on the Page Layout.
Click Save.
Step 2: Creating a Checkbox Field on Account Object
Click Setup.
In the Object Manager, type Account.
Select Fields & Relationships, then click New.
Select Checkbox as Data Type, then click Next.
Enter Field Label and click the tab key, the API Name will populate.
As a best practice, always input a description.
Default Values: Unchecked
Set the Field-level Security for the profiles, make sure to set this field as read-only.
Do not add this field on the Page Layout.
Click Save.
Step 3: Map Custom Lead Fields for Lead Conversion
Click Setup.
In the Object Manager, type Lead.
Select Fields & Relationships, then click Map Lead Fields.
You can map each of your organization’s Lead custom fields to one of your custom Account, Contact, or Opportunity fields.
Map the Lead Conversion field as shown in the screenshot below.
Click Save.
Step 4.1: Lightning Flow – Define Flow Properties
Click Setup.
In the Quick Find box, type Flows.
Select Flows then click on the New Flow.
Select the Autolaunched Flow (No Trigger) option and click on Nextand configure the flow as follows:
How do you want to start building: Freeform
Click Done.
Step 4.2: Lightning Flow – Add a Text Variable to Store Account Id
Under Toolbox, select Manager, then click New Resource to pass the store Account Id.
Input the following information:
ResourceType: Variable
API Name: varTAccountId
Data Type: Text
Default Value: {!$GlobalConstant.EmptyString}
Check Available for Input
Check Available for Output
Click Done.
Step 4.3: Lightning Flow – Add a Delete Records Element to Delete System Generated Post
Drag-and-drop Delete Records element onto the Flow designer.
Enter a name in the Label field; the API Name will auto-populate.
For How to Find Records to Delete select Specify conditions.
Select the Account Feedobject from the dropdown list.
Set Filter Conditions
Row 1:
Field: ParentId
Operator: Equals
Value: {!varTAccountId}
Click Done.
In the end, Warren’s Flowwill look like the following screenshot:
Once everything looks good, perform the steps below:
Click Save.
Enter Flow Label theAPI Name will auto-populate.
Click Show Advanced.
API Version for Running the Flow: 50
Interview Label: Delete system generated post {!$Flow.CurrentDateTime}
Click Save.
Almost there! Once everything looks good, click the Activate button.
Our next task is to create a Process on theAccount object to launch a Flow, only when an account is created from lead conversion.
Step 5.1: Define Process Properties
Click Setup.
In the Quick Find box, type Process Builder.
Select Process Builder, then click New.
Name the Process and click the Tab button. The API Name will populate.
As a best practice, always input a description.
The process starts when A record changes.
Click Save.
Step 5.2: Define Evaluation Criteria
Click on the Add Object node to begin selecting the evaluation criteria.
Select the Account object from the dropdown list.
Start the process only when a record is created.
Click Save.
Step 5.3: Define Process Criteria
Click the Add Criteria node to begin defining the process criteria.
Name the criteria.
The criteria should execute actions when the conditions are met.
Set Conditions
Row 1
Field: Account | Lead_Conversion__c
Operator: Equals
Type: Boolean
Value: True
Select All of the conditions are met (AND).
Click Save.
Step 5.4: set time for actions to execute
Below Scheduled Actions, click Set Schedule.
Set Field Values:
Row 1:
0
Hours
After
CreatedDate
Click Save.
Step 5.5: Add Action – Flows
Below 0 Hours After CreatedDate Scheduled Actions, click Add Action.
For Action Type, select Flows.
Name the action.
Select Flow – Delete system generated post.
Set Flow variables:
Row 1
Field: varTAccountId
Type: Field Reference
Value: Account | Id
Click Save.
In the end, Warren’s Processwill look like the following screenshot:
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Now onwards, if a business user converts a lead, Process Builder will automatically trigger and launch the Flow. It will then delete the system generated post after a few minutes. Let’s test it out.
Below is the current status of lead Ms. Kristen Akinbefore conversion.
After you convert the Lead, you will be directed to the Account Detail page. Click on the Account Chatter feed.
Final Output
Wait a few minutes and refresh the Account detail page.
Check out the Account feed. The Chatter post will be 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.