How to Run Scheduler

Breezz framework allows you to run Step Group as a scheduled job. Below steps describe how we can configure our first Scheduler and use Step Group.


Step 1: Configure Breezz Scheduler & Add Step Group

So, what does this scheduler do? Scheduler will run our ToUpperCaseNameSteps Step Group every week on Sunday midnight for the records described by the Query in Job Configuration (Accounts that were created in the last 7 days). To do that we first need to define a schedule job, so head on to Breezz SetupDashboardSchedule Job.

Create New Scheduler Job Create New Scheduler Job

  • Name - Enter the name of our scheduler process.
  • Description - Briefly describe the functionality of the scheduler process.
  • IsActive and Feature Availability - Leave default values for these settings.
  • Job Type - Choose the type of job. For example, if we’re executing a job implementing the SchedulerJob interface, select Custom. However, in our case, we’ve opted for Step Group, allowing us to run a set of steps together. More information can be found here.
  • Execution interval - Define the period when the job will trigger. Select Saturday at 00:00, meaning the job will run every Saturday at midnight.
  • Record Level Security - Determines the level of record security at the Step Group level. For our purposes, Inherited Sharing suffices.
  • Step Group - If the Custom type is chosen, provide a class name. However, since we’ve selected Step Group, enter the API name of the Step Group.
  • SOQL Query - For a Custom job type, this would be a Job Configuration. Here, we enter a query defining the records for which the Step Group will be executed. Ensure the SOQL Query includes all fields intended for use in related Steps; an Advanced Builder can assist in creating this query.
  • Process Chunk Size - Here, specify the number of records to be used by future, queueable, or batch jobs. For now, the default value of 200 should be retained.

Step 2: Re-run Scheduler

Our Breezz Scheduler Config will take effect automatically within a few minutes, as the Scheduler checks for configuration changes every 10 minutes. To expedite this process, you can manually rerun the Scheduler. Follow these steps: navigate to Developer Console → Debug → Open Execute Anonymous Window and enter the command to abort the Scheduler process.

forvendi.BreezzApi.SCHEDULER.kill();

Then enter below command to run it again.

forvendi.BreezzApi.SCHEDULER.run();

Or simply go to Breezz AppBreezz SetupDashboard → and Stop Scheduler manually wait and start Scheduler again.

Kill Scheduler Kill Scheduler

To check if Scheduler correctly initializes the process go to the Breezz applicationScheduler JobsAll and check if ChangeNameToUpperCaseWeekly Job Name is on the list.


Step 3: Change Step Class

You can notice that even though the Step Group is executed by Scheduler, Account Names are not changing. This happens because the registered Step does not save changes in the Database. Let’s use the same code we used in Create Step Class.

 1// class need to extends forvendi.Step class
 2public with sharing class UppercaseNameFieldStep extends forvendi.Step {
 3
 4    public UppercaseNameFieldStep() {
 5        // public default constructor need to available
 6        // for the technical reasons we have to pass the class name -
 7        // without this, the framework will not be able to execute this step in async context and create correct logs
 8        super(UppercaseNameFieldStep.class.getName());
 9    }
10
11    public override Boolean initRecordProcessing(Object record, Object optionalOldRecord) {
12        // we can cast record parameter to SObject because step we are planning to pass list of Accounts
13        SObject sfRecord = (SObject)record;
14        String recordName = (String)sfRecord.get('Name');
15
16
17        sfRecord.put('Name', String.isBlank(recordName) ? '' : recordName.trim().toUpperCase().replace(' ', '_'));
18
19
20        // returning false - because we have all what we need to finish the process
21        return false;
22    }
23}

Now when the Scheduler will run, all Account records created in the last 7 days will be modified. To read more about Modification Context please check the Breezz API Class ModificationContext.