Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Alternate for scheduled apex using flow builder

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 27 Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Similares a Alternate for scheduled apex using flow builder (20)

Anuncio

Más de KadharBashaJ (20)

Más reciente (20)

Anuncio

Alternate for scheduled apex using flow builder

  1. 1. Salesforce Admin Group, Trichy Alternate for Scheduled Apex using Flow Builder
  2. 2. Kadhar Basha J Salesforce Admin Group, Trichy Trailblazer Community Group Leader MST Solutions Sundaravel J Salesforce Admin Group, Trichy Trailblazer Community Group Co-Leader MST Solutions Salesforce Admin Group, Trichy
  3. 3. Salesforce Admin Group, Trichy Speaker Padmavathy T MST Solutions
  4. 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. 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. 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. 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. 8. Scenario Logo • Update: Tasks’ status to Auto-Closed • Condition: If open non-recurring tasks’ Due date passed 7 days • Schedule: Daily
  9. 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){
  10. 10. Apex Code Logo List<Task> tasks = new List<Task>(); if(taskList.size() > 0) { for(Task tsk : taskList) { tsk.Status = 'Auto-Closed'; tasks.add(tsk); } }
  11. 11. Apex Code Logo if(tasks.size()>0) update taskList; } global void finish(Database.BatchableContext BC) { } }
  12. 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); }
  13. 13. Alternate Elements for Apex Code Logo if(taskList.size() > 0) {}
  14. 14. Alternate Elements for Apex Code Logo for(Task tsk : taskList) {}
  15. 15. Alternate Elements for Apex Code Logo tsk.Status = 'Auto-Closed';
  16. 16. Alternate Elements for Apex Code Logo List<Task> tasks = List<Task>(); .. .. newtasks.add(tsk);
  17. 17. Alternate Elements for Apex Code Logo update taskList;
  18. 18. Alternate Elements for Apex Code Logo Scheduling a flow using Apex, Anonymous window or CRON Expression or through Configuration
  19. 19. Launch DEMO
  20. 20. 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
  21. 21. 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
  22. 22. 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.
  23. 23. 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
  24. 24. 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
  25. 25. 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.

×