Getting Started with Salesforce Flow – Part 32 (Preschedule Chatter Posts)

Getting Started with Salesforce Flow – Part 32 (Preschedule Chatter Posts)

Last Updated on December 30, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

How do you allow your users to preschedule Chatter posts?  

Chatter is a great way to boost collaboration in your organization. You can Post Status, Links, Files, and Comments on others’ posts, etc. Many time I found on Trailblazer community people is asking about a way to Preschedule Chatter Posts. But Salesforce doesn’t have any out-of-the-box feature for this, so the next way is to use the AppExchange app.

In this article, I will show, how you can develop your own app for scheduling Chatter Posts too without code.

Objectives:

After reading this blog post, the reader will be able to:

  • Use After-save Record-Triggered Flow to create a record
  • Use After-save Record-Triggered Flow to delete a record(s)
  • Add a Scheduled Paths action in After-save Record-Triggered Flow
  • Monitor Time-based flow queue

Business Use case

Pamela Kline is working as a System administrator at Universal Containers (UC). She has received a requirement from the management to allow their users to preschedule Chatter posts. Which will help them to schedule posts ahead of time, for example, birthday wishes, or other important announcements. 

Automation Champion Approach (I-do):

Salesforce now (After Spring’21 Release) allows you to add time-dependent actions in the Flows, similar to the Process Builder. This is a major enhancement that will ultimately bring Flow to the next level. 

There are few solutions possible for the above business scenario, but we’ll use After-save Record-Triggered Flow to solve it. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

Before proceeding ahead, you have to understand the FeedItem object. It represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.

Field Name Details
Body This is the message that appears in the feed.
ParentId The ID of the object type to which the is related. For example, set this field to a UserId to post to someone’s profile feed, or a GroupId to post to a specific Group.
Type The type of feed item. In our case it’s Textpost.

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 Pamela’s business requirement using After-save Record-Triggered Flow. We must:

  1. Create a custom object that will be used to store pre-schedule Chatter posts
  2. Salesforce Flow
    1. Define flow properties for record-triggered flow
    2. Add a scheduled path
    3. Add a create records element to post a message to chatter
    4. Add a delete records element to delete pre-scheduled post record

Step 1: Create a Custom Object 

The first step is to create a custom object Schedule Chatter Post and a few custom fields to store related information which will use in Salesforce flow. 

In this example, I have used User’s Wall field as a lookup to the user where you can select another user. If you want to use the same field for both users or groups then change this field data type to Text and then you have the ability to enter the Id of the user or Group where you want to post.

Name Data Type Required Description
Message
TextArea(255) Yes Type your message here
Post date Date/Time Yes Enter the date when you want to post the message
User’s Wall Lookup (User) Yes Where you want to post a message (Any specific user’s wall)
  1. Click Setup.
  2. In the Object Manager, click Create | Custom Object.
  3. Now create a custom object Schedule Chatter Post and fields as shown in the screenshot below: 
  4. Click Save.
  5. Make sure to associate the Tab with the object, so that users can access it.

Step 2.1: Salesforce 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 Record-Triggered Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created
    3. Run Flow: After the record is saved
    4. Object: Schedule Chatter Post
    5. Set Conditions: None
  5. Click Done.

Step 2.2: Salesforce Flow – Add Scheduled Paths

  1. Under Start, select Add Scheduled Paths (Optional).
  2. Under SCHEDULED PATHS, click on the  New Scheduled Path.
  3. Under Scheduled Path Details, enter the Label the API Name will auto-populate.
  4. Time Source: Scheduled_Chatter_Post__c:Post Date
  5. Offset Number: 0
  6. Offset Options: Hours After
  7. Click Done.

Step 2.3 Salesforce Flow – Add a Create Records Element to Insert a Record Into FeedItem Object 

 The next step is to post a message to chatter, 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: FeedItem
    5. Set Field Values for the Feed Item
    6. Row 1:
      1. Field: Body
      2. Value: {!$Record.rakeshistomMVP__Message__c}
    7. Click Add Row
    8. Row 2:
      1. Field: ParentId
      2. Value: {!$Record.rakeshistomMVP__User_s_Wall__r.Id}
    9. Click Add Row
    10. Row 3:
      1. Field: Type
      2. Value: TextPost
  3. Click Done.

Step 2.4: Salesforce Flow – Add a Delete Records Element to Delete the Scheduled Chatter Post

  1. Drag-and-drop Delete Records element onto the Flow designer. 
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. For How to Find Records to Delete select Use the IDs stored in a record variable or record collection variable.
  4. Set Record(s) to Delete
    1. Record or Record Collection: {!$Record}
  5. Click Done.

In the end, Pamela’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: 51
  5. Interview Label: Preschedule Chatter Posts {!$Flow.CurrentDateTime}
  6. Click Save.

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

Proof of Concept

Now onwards if a user is created a record in the Schedule Chatter Post object, Salesforce Flow will automatically post the message to Chatter Based on the Post Date field.

  1. Create a New scheduled post record.
  2. Wait until post date and then check Tushar’s chatter profile.

Monitor Your Schedule Flow

To monitor Flows that are scheduled, navigate to the following path: 

  1. Navigate to Setup (Gear Icon) | Environments | Monitoring | Time-Based Workflow.
  2. Now look for your Scheduled Flow job displaying information as shown in the following screenshot:
  3. Use the Delete button to delete the time-based Flow job from the queue.

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.

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

 

4 thoughts on “Getting Started with Salesforce Flow – Part 32 (Preschedule Chatter Posts)

  1. Hi Rakesh,

    I am just checking this, I am not able to see New Flow ( Step 6) in my instance, Could you please help me in this..

Leave a Reply

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