4. Today’s Agenda
• What is a Schedule-Triggered Flow?
• Things to Note
• Apex Code - Example
• Alternate Elements for Apex Code
• Demo
• Questions & Answers
• Conclusion
5. What is a Schedule-Triggered Flow?
Logo
• It is an auto-launched flow introduced in Winter’20 release
• We can schedule it to start at a specific date and time
• Different frequencies to run
Once
Daily
Weekly
• Runs for each record in the batch and stores record’s field values in
the $Record global variable.
• Scheduled-Trigged Flow always runs in System mode.
6. Things to Note
Logo
• The Start Time is based on the Salesforce org’s default time
zone.
• Start Time differs based on user’s time zone.
• View All Data permission required.
• Flow interviews per 24 hours is 2,50,000
• Flows are bulikfied
• We can see debug of the scheduled flow in debug logs
• We can track the number of records with the
FLOW_START_SCHEDULED_RECORDS event
7. Things to Note
Logo
• Deleting a schedule-triggered flow interview from the Scheduled
Jobs, all future recurrences of that flow are cancelled.
• Run as the Automated Process user.
• Enable Filter inaccessible fields from flow requests in your org’s
process automation settings. Otherwise, the flow fails because
the Update Records element tries to set the values for system
fields and other read-only fields.
• Using multiple filters defaults to AND for different fields.
8. Scenario
Logo
• Update: Tasks’ status to Auto-Closed
• Condition: If open non-recurring tasks’ Due date passed 7 days
• Schedule: Daily
9. Apex Code
Logo
global class CloseTasks_AC implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'SELECT Id, Status, Due_Date_Passed__c,
IsRecurrence FROM Task WHERE IsClosed = False AND
Due_Date_Passed__c = True AND IsRecurrence = False';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Task>
taskList){
12. Alternate Elements for Apex Code
Logo
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = 'SELECT Id, Status, Due_Date_Passed__c, IsRecurrence FROM Task WHERE
IsClosed = False AND Due_Date_Passed__c = True AND IsRecurrence = False';
return Database.getQueryLocator(query);
}
21. Quiz
Logo
1) A screen flow can be launched using a custom link.
True
False
Ans: True. /flow/flow_Name
2) Schedule-Triggered flow can be scheduled monthly
True
False
Ans: False
22. Quiz
Logo
3) Can we create formula to filter records in flow?
Ans: No. We cannot directly create formula in flow.
We can create a formula field and use it in the flow.
4) Can we change the datatype of the variable created in the flow?
Ans: No
23. Quiz
Logo
5) Where can we find the scheduled flow interviews?
Ans: Scheduled Jobs
6) What will happen when we delete the flow interviews of active flow in
scheduled jobs?
Ans: Future recurrences of that flow are cancelled. To enable future runs,
deactivate and reactivate the flow.
24. Quiz
Logo
7) Which interface needs to be implemented in apex to be used in
the flow?
Ans: Using @InvocableMethod annotation with Static method
8) Where we can find all the elements used in the current flow?
Ans: Manager tab in the left panel
25. Quiz
Logo
9) A flow is failing as it tries to update the system and read only fields.
What you should do to get rid of this error?
Ans: Enable “Filter inaccessible fields from flow requests” in your org’s
process automation settings.
10) What will be the time zone for the date/time field values at run time?
Ans: Values reflect the time zone settings of the running user
26. Conclusion
• New version of Flow contains all those options which is available after
wrote a huge lines of code in Apex.
• We are free from test classes.
• Are you a low code lover, then you should proceed with the
automation.