Monday, September 27, 2021

Salesforce Flow Tutorial #3 - What is Record Triggered Flow - Post To Chatter

 In this tutorial we will learn how to create and use Record Triggered Flow. The Record triggered flow can be used to fulfill requirements which requires us to write Trigger in Apex. Record Triggered Flow can be executed when 

  • A record is created
  • A record is updated
  • A record is created or updated
  • A record is deleted.
We can run the flow 
  •  Before the record is saved.
  •  After the record is saved.
Our hypothethical business users requirement is that when a new lead record is created in our Salesforce org, we must post a message to chatter. To handle different types of leads we have different chatter groups. Leads can have rating of Hot,Warm and Cold. 

Here we will learn several new things 

  • A little bit of Chatter
  • Use of Action to post something to chatter
  • Use of Labels in a flow
  • Use of Record Triggered Flow
Chatter - Chatter is a Salesforce real-time collaboration tool that lets your users work together, talk to each other, and share information. You can relate it to Whatsapp, Instagram messenger, etc.

So lets start by first enabling chatter in the org. Check the settings from Setup and make sure that it is enabled.







Once chatter is enabled, search for chatter in App Launcher and open Salesforce Chatter. Once the app opens, open the chatter tab.








Now let us create 3 different public Groups based on the Lead Rating i.e. Hot, Warm and Cold Groups. Different agents/people can be assigned to the public groups to work on these leads. 
Below are the steps to create a Hot Lead Group. You need to create similar groups for Warm and Cold.












Now lets create some labels which we will use in the flow. Search for Label menu item in the setup menu. Labels are used in Salesforce to store configurable Text or any values.



Create a label for "Hot Leads" and provide the Salesforce Group Id of the Hot Leads group in Chatter. You can get the Salesforce Id from the Group URL when you click on the group name in the chatter.


Similarly create the Labels for Warm and Cold Leads. This is how it will be look like once all the labels are created.



Once we have all the configuration and pre-requisite in place, now lets create the flow. Create a new flow and select "Record Triggered Flow" option.



By default this is how the flow will look like. Click on "edit" link.

Make sure that the option "Trigger the flow when" - "A record is created" is selected. And for "Run the flow" we have "After the record is saved" is selected.


Choose lead object by clicking on the "Choose Object" link. Select Lead Object and change the condition so that there is no condition requirement.











Now let us create 3 different text messages that we will post on chatter for Hot,Warm and Cold Lead respectively. Message for Hot Lead is shown below.




Now click on the "+" icon to add a decision element on the canvas. We will configure conditions for "Hot", "Warm" and "Cold" outcomes in the decision box. Here we will simply configure the rating field in the condition. Click on the "+" icon in the decision box to add additional outcomes








 

Now click on the "+" icon in the "Hot Lead?" outcome to add a chatter action.

In the new action box, search for messaging action. When you open the drop down you will see, "Post to Chatter" action. Here we will select the message that we want to post and the Group id, which we configured in the Label. In the Target Name or Id field, you will have to put the group id.





Do the same for Warm and Cold outcomes. After the outcomes are configured, this is how the flow will look like





Now save and activate the flow. To test this flow, we will have to create a new lead record in the org.



Go to the chatter tab, you will see a new message is posted in the chatter group



No comments:

Salesforce Flow Tutorial #3 - What is Record Triggered Flow - Post To Chatter

 In this tutorial we will learn how to create and use Record Triggered Flow. The Record triggered flow can be used to fulfill requirements w...