Getting Started with Process Builder – Part 55 (Post to Chatter Feed of Related Record)

Getting Started with Process Builder – Part 55 (Post to Chatter Feed of Related Record)

Last Updated on December 19, 2020 by Rakesh Gupta

To understand how to solve the same business use case using Salesforce Flow. Check out this article Getting Started with Salesforce Flow – Part 34 (Post Opportunity Details to a Chatter Group).

Big Idea or Enduring Question:

  • How can you automatically post a message to the Chatter feed of related records?

Chatter is a great way to boost collaboration in your organization. In this article Getting Started with Process Builder – Part 13 (Auto Post a Message to Chatter When an Event is Created), I had discussed a use case, whenever an event is created for the public calendar post its detail to a Chatter Group using the Process Builder. This article goes a step ahead and explains, how someone uses Flow and Process Builder to post to Chatter Feed of Related Record.

Objectives:

This blog post will help us to understand the following

  • Create a Process Builder and Flow to auto-post message to chatter feed of the related record 
  • Understand how to use Flow to create a record

Business Use Case

Donna Serdula is working as a System administrator at Universal Containers (UC). She has received a requirement from the management to post opportunity details (with Opportunity link) to the related Account’s feed, whenever an opportunity gets created with an amount greater than $100k.

Automation Champion Approach (I-do):

There are a few possible solutions for the above business scenario. We will use Process Builder and Flow to solve it.

Let’s take a minute’s pause here and understand FeedItem objects in Salesforce. It represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts. 

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 2 steps to solve Donna’s business requirement using Process Builder and Flow. We must:

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a record variable to store opportunity record details 
    3. Add a get records element to find Salesforce Instance details
    4. Add a create records element  – post a message on related record feed
  2. Process Builder Steps:
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – flows 

Step 1.1: Lightning Flow – Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. Click Done.

Step 1.2: Lightning Flow – Add a Record Variable to Store Contact Record Data

  1. Under Toolbox, select Manager, then click New Resource to store Contact Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varROpportunity
    3. Data Type: Record
    4. Object Opportunity
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Adding a Get Record Element to Find Salesforce Instance Details

The next step is to find the org’s Salesforce instance name and other details. 

  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 Organization object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Does Not Equal
      3. Value: {!$GlobalConstant.EmptyString}
  7. How Many Records to Store:
    1. select All records
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

 

Step 1.4: Lightning Flow – Add a Post a Message on Related Record Feed 

The next step is to post a message (Type: – Link Post) to Account Feed, for this 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 separate resources, and literal values
    4. Object: Feed Item
    5. Set Field Values for the Feed Item
    6. Row 1:
      1. Field: Body
      2. Value: An Opportunity gets created with an amount of more than 100K.
    7. Click Add Row
    8. Row 2:
      1. Field: LinkUrl
      2. Value: https://{!Find_Instance_Id.InstanceName}.salesforce.com/{!varROpportunity.Id}
    9. Click Add Row
    10. Row 3:
      1. Field: Title
      2. Value: {!varROpportunity.Name}
    11. Click Add Row
    12. Row 4:
      1. Field: Type
      2. Value: LinkPost
    13. Click Add Row
    14. Row 5:
      1. Field: Visibility
      2. Value: InternalUsers
    15. Click Add Row
    16. Row 6:
      1. Field: ParentId
      2. Value: {!varROpportunity.AccountId}
  3. Click Done.

In the end, Donna’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: 50
  5. Interview Label: Post to Chatter Feed of Related Record {!$Flow.CurrentDateTime}
  6. Click Save

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

Our next task is to create a Process on the Opportunity object to Launch a Flow, only when the opportunity is created with an amount is greater than 100,000. To create a Process on the Opportunity object, follow the instructions below:

Step 2.1: Define Process Properties

  1. Click Setup.
  2. In the Quick Find box, type Process Builder.
  3. Select Process Builder, then click New.
  4. Name the Process and click the Tab button. The API Name will populate. 
  5. As a best practice, always input a description
  6. The process starts when A record changes.
  7. Click Save.

Step 2.2: Define Evaluation Criteria

  1. Click on the Add Object node to begin selecting the evaluation criteria.
  2. Select the Opportunity object from the dropdown list.
  3. Start the process only when a record is created.
  4. Click Save.

Step 2.3: Define Process Criteria

  1. Click the Add Criteria node to begin defining the process criteria.
  2. Name the criteria.
  3. The criteria should execute actions when the conditions are met.
  4. Set Conditions
    1. Row 1
      1. Field: Opportunity | AccountId
      2. Operator: Is null
      3. Type: Boolean
      4. Value: False
    2. Add Row
    3. Row 2
      1. Field: Opportunity | Amount
      2. Operator: Greater than
      3. Type: Currency
      4. Value: 100,000
  5. Select All of the conditions are met (AND)
  6. Click Save.

Step 2.4: Add Action – Flows

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the flow we just createdPost to Chatter Feed of Related Record.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varROpportunity
      2. Type: Field Reference
      3. Value: Select the Opportunity record that started your process
  6. Click Save.

In the end, Donna’s Process will look like the following screenshot:

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

Proof of Concept

If a sales rep creates or updates the opportunity with an amount of more than $100k, Process Builder will fire and automatically post a message to the related Account feed.  

  1. Navigate to the Opportunities tab and create a new Opportunity record with an amount of 1.1 M, as shown in the following screenshot:
  2. Check out the Account Feed section on the Account page.

Formative Assessment:

I want to hear from you! 

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

Make a post and tag me on Twitter @automationchamp, using #AutomationChampionPB.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

One thought on “Getting Started with Process Builder – Part 55 (Post to Chatter Feed of Related Record)

  1. Hi Rakesh,

    In the above post,why didn’t you use Account feed to post to the Account?.Any specific reasons for choosing feed item object instead of Account feed.Can we use Account Feed object instead of Feed Item Object?
    Thanks

Leave a Reply

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