Post Opportunity Details to a Chatter Group

Post Opportunity Details to a Chatter Group

Last Updated on April 4, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you post a message to the chatter group via Salesforce Flow? 

Chatter Group represents a group of users who can share and collaborate on mission-related files and information. It’s a great way to boost collaboration in the organization. Chatter Groups can have unlimited members, but a user can join a maximum of 300 Groups. Users can post message on Chatter Group when an Object record is created, so users don’t need to check their mailbox every time and this will provide a way to boost collaboration in organizations.

Objectives:

After reading this blog, you’ll be able to: 

  • Understand FeedItem object
  • Use After-save Record-Triggered Flow to create a record
  • Use After-save Record-Triggered Flow to Post a message to Chatter
  • Use a Decision element to find – record variable or record collection variable contains a record or not

Business Use Case

Pamela Kline is working as a System administrator at Universal Containers (UC). His organization wants to post a message with a record (opportunity) link to the Chatter Group UC Internal Announcements, whenever an opportunity is created with an amount greater than $10000. 

Automation Champion Approach (I-do):

While this can be solved using various automation tools like Process Builder, Apex Trigger, or Flow, we will use After-save Record-Triggered Flow. 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 LinkPost.
LinkUrl  The field contains the URL of the opportunity record.
Title The field contains the title of the Chatter post.

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 4 steps to solve Warren’s business requirement using Salesforce Flow. We must:

  1. Create a chatter group
  2. Find the chatter group Id
  3. Creating a custom label to store chatter group Id
  4. Salesforce Flow
    1. Define flow properties for record-triggered flow and condition to check the opportunity amount
    2. Add a get records element to find Salesforce Instance details
    3. Add a create records element to post a message to the chatter group 

Step 1: Create a Chatter Group

  1. Navigate to App Launcher and click on the Groups.
  2. Clicks on the New button. 
  3. Name the Group and make sure to select the Private Access Type.
  4. Click Save.

Step 2: Find the Chatter Group Id for UC Internal Announcements 

The next step is to find out the Id of the chatter group UC Internal Announcements. One possible workaround is to use the Developer Console. 

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. Select id, name from collaborationgroup where (name=’UC Internal Announcements’)
  3. Make sure to copy the Id. 

Step 3: Creating a Custom Label to Store Chatter Group Id

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the UC Internal Announcement chatter group id in the Value.
  6. Click Save.

Step 4.1: Salesforce Flow – Define Flow Properties 

As we have a requirement of creating a record in (FeedItem) when an opportunity is created with an amount is greater than $10k. This is why we have to use the After-save flow on Opportunity.

  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: Opportunity
  5. Select All Condition Are Met (AND)
  6. Set Conditions
    1. Row 1
      1. Field: Opportunity | Amount
      2. Operator: Greater Than
      3. Value: 10000
  7. Click Done.

Step 4.2: Salesforce 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 4.3: Salesforce Flow – Create Records – Post a Message to Chatter Group ‘UC Internal Announcements’ 

The next step is to post a message to the chatter group with an opportunity link. 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. Row 1:
        1. Field: Body
        2. Value: An Opportunity gets created with an amount of more than 10K.
      2. Add Field
      3. Row 2
        1. Field: LinkUrl
        2. Value: https://{!Find_Instance_Details.InstanceName}.salesforce.com/{!$Record.Id}
      4. Add Field
      5. Row 3
        1. Field: ParentId
        2. Value: {!$Label.UC_Internal_Chatter_Group_ID}
      6. Add Field
      7. Row 4
        1. Field: Title
        2. Value: {!$Record.Name}
      8. Add Field
      9. Row 5
        1. Field: Type
        2. Value: LinkPost
  3. 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: Post to Chatter Group {!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

If a sales rep creates the opportunity with an amount of more than $10k, Flow will fire and automatically post a message to the UC Internal Announcements Chatter Group.  

  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  UC Internal Announcements Chatter Group.

 

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 #AutomationChampion.

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

10 thoughts on “Post Opportunity Details to a Chatter Group

  1. Why are we using Organization as object in Get Record element. I tried with Opportunity and it throwed an exception.
    And Feed Item in create records element.
    Please explain

    1. To answer your question – We are using Organization as object in Get Record element to find Instance Id so that later in the flow, we can use it to construct the dynamic URL.

  2. Rakesh, I really appreciate your blog. It is very insightful! Thanks.

    Question: with this scenario, could field data be posted to a Chatter group that includes customers? Here is the situation: my users are owners of properties in a motor home resort. They typically live hundreds or thousands of miles away. The complex is allowing the construction of small buildings called Coach Houses on the individual owner properties. The property owners need to get updates on the construction process, ask questions of board members, and collaborate with builders. To save money I’m building an EE org. 1 EE and several chatter plus licenses for board members. If necessary I’ll add more Chatter plus but I’d rather just set up a public group with customers for each property owner. They would then get a Chatter free license each. Saving the association the cost of Chatter plus licenses. If I do this, can I feed field data to the Chatter free users through their individual Chatter free public group using a Process? Property owners don’t need to see the objects. They just need to be fed their data.
    Can I do this? Or what would you recommend as the solution for it.

  3. Thanks for the great post.

    Could you share your dev org credentials where this feature is enabled(As it takes 2 weeks to enable pilot in the Dev org).

    This is really urgent me to test this feature. Thanks in advance.

Leave a Reply

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