What are Schedule-triggered Flows?
Schedule-triggered flows start up at predetermined intervals and let you automate Salesforce activities. Teams can greatly benefit from this kind of automation in a variety of use situations. As an illustration, suppose the accounting division is in charge of controlling account activation and deactivation in Salesforce. They currently run reports once a week and manually change an account's status from active to inactive based on the start and end dates of the contract. A schedule-triggered flow can be used to implement accounting's request for automation that checks the contract start/termination dates every night and automatically activates or deactivates these accounts!
We must first establish a brand-new flow and choose the Schedule-Triggered Flow option. Click the Start element when the Flow Builder has opened. Here, you have two choices:
- Set a Schedule
- Pick an Item
As this will enable us to choose the start date, start time, and frequency of the flow, we'll want to start by clicking Set a Schedule. For the purposes of this example, we'll set the flow to begin on October 19 and continue every night at 1:30 am.
Don't forget to check out: What is the Flow Builder In Salesforce in 2023?
The fact that the Start element behaves like a Get Records element must be noted. This run will really execute this flow for one record at a time when it is triggered. There is no need for you to loop through your findings because each record is saved in a single record variable named $Record.
We must decide which object will be queried when the schedule-triggered flow begins because our Start element is searching for our records. Click Choose Object to start. We'll choose the account object for our example. To narrow down the list of accounts you query, you can specify specific criteria.
Criteria for Scheduled Trigger Flows
- None — Run Flow for All Accounts
- If Both Conditions Are True (AND)
- The logic for a Custom Condition is met (OR)
- Due to the limited alternatives, it is usually preferable to incorporate your logic into the flow later on using a Decision element.
- In order for all of our account records to go through our flow, we will choose None — Run Flow for All Accounts in our Start element.
- Select Done after selecting your object and filter criteria. You have now completed the Start element.
- Constructing a schedule-triggered flow's logic
After finishing the Start element, we'll build the flow's unique logic.
Check out another amazing blog here: An Introduction to Screen Flow in Salesforce in 2023
Based on the start or end date of the contract, we want to automatically update the relevant entries in this instance. To do this, the flow will initially require some logic to determine the current date. Let's construct a formula variable that returns the current date using the New Resource area of the left-hand toolbar. Date data type will be used, and the formula TODAY will be entered (). Additionally, we'll call the API returnTodaysDateFormula.
Now that we have a formula that gives the current date, we can use it in our Decision element to determine whether or not the account should be active.
To accomplish this, we'll add a Decision element right after the Start element. If the object in the flow doesn't cause any modifications, the "default outcome" of each Decision element is automatically used. For your Decision element, you can design a variety of results. Here, we'll make two: one for account closure and one for account opening. Let's examine each's justification in more detail.