How to Create and Deploy Scheduled-Trigger Flow in Salesforce

The flows are the most powerful automation tool provided by Salesforce. Schedule-Trigger Flow launches at a specific time for each record in that batch.

In this Salesforce tutorial, we will learn about creating a schedule trigger flow in Salesforce. We will see what a schedule trigger flow is and when we can use it.

Additionally, we will see how to create a schedule trigger flow in Salesforce with real-time scenarios with explanations.

Scheduled-Trigger Flow in Salesforce

What is Scheduled-Trigger Flow in Salesforce?

The flows are the most powerful automation tool provided by Salesforce. This flow launches at a specific time for each record in that batch. So far, we have used the Apex batch job to fulfill this requirement, but now we can also use flows.

When can we use Scheduled-Trigger Flow in Salesforce?

  • When we want to perform any automated task and execute it frequently, once, daily, or weekly, with specific meeting criteria, we can use schedule trigger flow.
  • With the scheduled trigger flow, we can avoid writing code in Apex triggers in some conditions.
  • We can also use scheduled trigger flows for simple automation and notification work to send an email or notification frequently at the same time.

How to Create a Scheduled Trigger Flow in Salesforce

Scenario:

There is a finance company, JPMorgan Chase Pvt. Ltd. In that company, The finance team wanted to automate reminder emails to notify the customer before two days of the due date to submit the loan EMI Amount.

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

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

Scheduled Trigger Flow in Salesforce

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

New Scheduled Trigger Flow in Salesforce

3. We want to create a flow for sending an email, so we have to select the Schedule-Trigger flow. Then, click on the Create button.

What is Scheduled Trigger Flow in Salesforce

4. Now select the Start Date and Time. From the selected date and time, the flow will start to execute. The Frequency is set to Daily because we want to execute this task on a daily basis. The Once is used when we want to execute this flow only once.

What is a Scheduled Trigger Flow in Salesforce

5. You can see the flow chart displayed with the selected option in the above steps. Now, we need to create the formula for notifying two days before the due date.

See also  How to Send Custom Notification using Flow in Salesforce

To create a formula, click the Manager Tool and select New Resource.

Create a Scheduled Trigger Flow in Salesforce

6. Then, you will see the New Resource window, in which you enter the necessary information. We want to create a formula for that select Resource Type as Formula.

The API Name will automatically populate as we click the text box. The Description is optional; we can introduce this formula shortly.

If we want to send an email two days before the given date, then we can create a formula like (Current date + 2). This will return the notify date two days before the due date. Then click on the Done button.

How to Create Scheduled Trigger Flow in Salesforce

7. Now, we need to fetch the records to check the due date of EMI; for that, click on Get Records Element. Enter the label as per your requirement, and the API Name will automatically populate.

Then, select the object from which you want to retrieve records. Here, I have stored customer data in the account object, so I have selected the Account object.

Uses of Scheduled Trigger Flow in Salesforce

8. Then, we will check if the due date equals the date we created in the formula resource. Then, we need to send emails to those customers.

Create Scheduled Trigger Flow in Salesforce

9. We have to check the above condition with all records. For that, click on the “All records” to store. Then, in how to store record data option, click on the Choose field and let Salesforce do the rest. You can select “Automatically store all fields also.”

Then click on the Done button.

How to Create a Scheduled Trigger Flow in Salesforce

10. Then, we need to check all records with the schedule criteria that we have defined above. To check them one by one, we have to create a loop on the records.

See also  How to Add Record Type in Salesforce Flow

For that, click on the Loop element. As we click on the element, we will see the New Loop window. In that, we have to enter the Label, and the API Name will automatically populate.

The Description is optional; we can introduce our loop shortly. Then, in the Collection Variable, we need to pass records that we have stored in the Get Records Element. After that, click on the Done Button.

Create a Scheduled Trigger Flow in Salesforce Lightning

11. Then add an Action element to send the email to the customer. For that, click on the For Each loop option, where all records are processed. After clicking on Add Action, click on Email Action.

Create Scheduled Trigger Flow in Salesforce Lightning

12. When we click on Email Action, the Edit Send Email Window will open, and we need to set the Label and API name. Now, we need to add an email body; for that, click on the include button, click on body text, and select the New Resource, where we can create the Email Body.

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 field, select the recipient email from the records that we have stored in Loop.
  • Rich text box: Using this we can allow HTML links in the email body.
  • Subject: I have entered the subject “Lone EMI due Date Reminder.”
  • Sender Email: Do not click on this button because it considers only the sender email address of the person who created the records.
Scheduled Trigger Flows in Salesforce

14. 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 introduce our flow Shortly.

See also  Clone Records with their Related records in Salesforce using Flow

Then click on the Save button.

Create a Scheduled Trigger Flow in Salesforce example

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

15. Here, you can see I have got an email two days before.

Schedule trigger flow in Salesforce

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

Conclusion

I hope you have an idea about creating a schedule trigger flow in Salesforce. We have seen what a schedule trigger flow is and when we can use it. Additionally, we have also seen how to create a schedule trigger flow in Salesforce with real-time scenarios and explanations.

You may like to read: