Create Record Trigger Flow in Salesforce | What is Record Trigger Flow in Salesforce

The record-trigger flow launches when a record is created, updated, or deleted. Usually, we use an Apex trigger to achieve this task, but now we can also use the flow.

In this Salesforce tutorial, we will learn about record trigger flow in Salesforce. In this article, we will see the record trigger flow and when we can use it.

Additionally, we will see how to create record trigger flow in Salesforce Lightning and Salesforce Classic with an example.

Record Trigger Flow in Salesforce

What is Record-Trigger Flow in Salesforce?

The record trigger flow is an automated process that executes automatically on record creation, update or deletion. Usually, we use an Apex trigger to achieve this task, but now we can also use the flow. You can trigger a flow when:

  • A record is created.
  • A record is updated.
  • A record is created or updated.
  • A record is deleted.

When can we use record trigger flow in Salesforce?

  • When we want to perform any automated task, then first check if it is not complex, then start with the flow.
  • With the record trigger flow, we can avoid writing code in Apex triggers in some conditions.
  • The record trigger flow is called when any DML operation occurs, such as record creation, update, or deletion.
  • We can also use Salesforce flows for simple automation and notification work.
  • The record trigger flow updates the record 10 times faster than the record change process.

How to Create Record-Trigger Flow in Salesforce Lightning

Scenario:

There is a company, Hyperlink Infosystem Pvt. Ltd. In that company, The sales team wanted to automate the opportunity stages pipeline with the criteria that If the amount is greater than 1 lakh, then the opportunity stage will be closed won; otherwise, it will be set to close lost.

We can create a record trigger flow in Salesforce Lightning using the above scenario and the following steps.

1. Log in to the Salesforce Org. -> Click on the Setup. -> Home Tab. -> Search for Flows. You will see an option under Process Automation. -> Click on Flows.

Record trigger flow in Salesforce Lightning

2. Click on the New Flow button to create a new flow.

New Record trigger flow in Salesforce Lightning

3. We want to create a flow for creating the records, so we have to select the Record-Trigger flow. Then, click on the Create button.

Create a Record trigger flow in Salesforce Lightning

4. Here, in the Object field, we need to select which object we want to create flow. In our scenario, we need to create flow on Opportunity Object. In the Configure Trigger option, we need to select when we want to invoke this flow.

How to Create Record trigger flow in Salesforce Lightning

5. In the Set Entry Conditions, we have to select the initial condition. When this condition matches our value, the flow will start to execute.

See also  How to Create a Note with Salesforce Flow

In tn the Condition Requirements, I selected the Amount value Greater than 0. If this condition meets the record criteria, the flow will start executing.

How to Create a Record trigger flow in Salesforce Lightning

6. In our scenario, when the amount value is greater than 1 lakh, the stage should be set to “close won.” In this requirement, the value must be changed before the record is saved to the database.

So, we have to select Fast Field Update, which is used when we want to execute flow before the record is saved to the database.

Record trigger flow in Salesforce Lightning example

7. You can see the flow chart displayed with the selected option in the above steps.

Record trigger flow in Salesforce Lightning examples

8. We need to add a condition. We use the Decision element to add a condition in flow. To add this element to the canvas, drag and drop the decision element onto the canvas. The decision element acts as an IF and Else statement.

Record trigger flow in Salesforce

9. As we drop the decision element on the canvas, this page will have an option; on this page, we have to enter the following information to create the decision.

  • Label: This label will display on the canvas where the decision element is. Here, I have entered the Check Opportunity Amount, which is displayed on the decision element.
  • Description: Description is optional; we can enter a short intro about our flow.

Outcome Details:

  • Label: This label is used to IF part of the decision, which means we can enter a label for this scenario like Check greater than.
  • Outcome API Name: It will automatically populate as we click the text box.
  • Condition Requirement to execute Outcome: In this dropdown field, we can select either we want to check all conditions, or we have another option also.
  • Criteria: As per the scenario, I entered the IF Amount Greater Than 100000.

Then click on the Default Outcome option and enter the details in the same way we entered in the above steps, and you can define the logic according to your criteria by entering the fields Resource, Operator, and Values.

Then click on the Done button.

Create a Record trigger flow in Salesforce

10. In the above steps, we have defined the condition criteria; now, we want to update the field value as per those criteria. Now, when we want to update the field, then click on the outcome circle and select the Update Training Records option.

How to Create New Record trigger flow in Salesforce Lightning

11. When we click on the Check greater than outcome circle, we have to select the field name from the object and also need to select a value to update in the record page.

Create a Record trigger flow in Salesforce Lightning example

12. After setting up all labels and conditions, click the Save button to save the flow. For that we need to enter the Flow Label; here, I have entered the Field Update Opportunity Flow. The API Name will automatically populate as we click the text box. The Description is optional; we can enter a short intro about our flow.

See also  How to Create Variables Using Flow Builder in Salesforce

Then click on the Save button.

How to Create New Record trigger flow in Salesforce example

13. It is best practice in the flow to always Debug the flow before activating it, and then, if no error occurs, Activate the flow.

New Record trigger flow in Salesforce Lightning example

14. To check whether the flow is working properly, go to the object on which you have created a flow. If you have selected trigger flow when the record is created, then create the record.

As per our scenario, if the amount is greater than 1 lakh, then the Stage should be set to Closed Won. Here, I have selected the Value Proposition, but as I click the Save button, this Stage field must display the value as “Closed Won.”

Salesforce Record Trigger Flow example

15. After saving the record, the Stage field value on the detail page has changed to Closed Won.

Salesforce Record Trigger Flow

This is how we can create a record trigger flow in Salesforce Lightning.

How to Create Record-Trigger Flow in Salesforce Classic

Scenario:

In Classic, we are using the same scenario as in Lightning. Additionally, we have to send an automated email to the sales team notifying them about the opportunity to win.

We can create a record trigger flow in Salesforce Classic using the above scenario and the following steps.

1. In Salesforce Classic, click on the Setup option, and then you will see the Quick Find Box in that search for the Flows object. Then, under the Workflow & Approvals option, you will see the Flows option; click on it.

Create a Record trigger flow in Salesforce Classic

2. Click on the New Flow button to create a new flow.

Create a Record trigger flow in Salesforce Classic example

3. We want to create a flow for creating the records, so we have to select the Record-Trigger flow. Then, click on the Create button.

How to Create a Record trigger flow in Salesforce Classic

4. Here, in the Object field, we need to select which object we want to create flow. In our scenario, we need to create flow on Opportunity Object. In the Configure Trigger option, we need to select when we want to invoke this flow.

How to Create Record trigger flow in Salesforce Classic example

4. In the Set Entry Conditions, we have to select the initial condition. When this condition matches our value, the flow will start to execute.

In tn the Condition Requirements, I selected the Amount value Greater than 100000. If this condition meets the record criteria, the flow will start executing.

Record trigger flow in Salesforce Classic examples

5. In this scenario, we want to email the sales team after saving the record. Email sending is an action for which we will use Action and Related Records.

How to Create Record trigger flow in Salesforce Classic

6. To add the email action, double-click the add action circle.

Record trigger flow in Salesforce Classic example

7. As you click on the add action, the following page will open under the Category option. You will see Email; click on that and enter the Label to send email action, and the API name will automatically populate.

Record-trigger flow in Salesforce

8. Then, we need to create the email template; for that, we can set input values for the selected action.

See also  How to Create and Deploy Scheduled-Trigger Flow in Salesforce

To create an Email Body, click on the include button so we can create an email body, then click on the New Resource.

In these input values, we need to set the following things:

  • Body: We have seen above how to enter body values.
  • Recipient address list: In this specify email list to whom you want to send an email.
  • Rich text box: Using this we can allow HTML links in the email body.
  • Subject: I have entered the subject “Notify Closed Won Opportunity.”
  • Sender Email: Do not click on this button because it considers only the sender email address of the person who created the records.
Create a Record trigger flow in Salesforce examples

9. Then we must select Resource type as Text Template, then enter that API Name as per your requirement; then enter the body text and click on Done.

How to Create Record trigger flow in Salesforce Classics

10. After setting up all labels and conditions, click the Save button to save the flow. For that, we need to enter the Flow Label; here, I have entered the Send Automate email. The API Name will automatically populate as we click the text box. The Description is optional; we can enter a short intro about our flow.

Then click on the Save button.

Record-trigger flow in Salesforce Classic

11. It is best practice in the flow to always Debug the flow before activating it, and then, if no error occurs, Activate the flow.

How to Create Record trigger flow in Salesforce Classic examples

12. Then, create a record on the opportunity object that matches the entry criteria, which is an amount greater than 1 lakh. You can see that after creating the record, I received mail that we entered in the email body.

How to Create a Record trigger flow in Salesforce Classics

This is how we can create a record trigger flow in Salesforce Classic.

Conclusion

I hope you have got an idea about record trigger flow in Salesforce. We have seen the record trigger flow and when we can use it. Additionally, we have seen how to create record trigger flow in Salesforce Lightning and Salesforce Classic with different scenarios.

You may like to read: