Example: Schedule Mass Actions with Process Builder, Flow, or Apex
Home > Getting Started > Examples > Schedule Mass Actions with Process Builder, Flow, or Apex
The main use case for Mass Action Scheduler is to declaratively define a schedule for Process Builder, Flows, Quick Actions, Email Alerts, Workflow Rules, and Apex to process records from Reports and List Views. However, you may want to have your configuration run for more arbitrary reasons than an always recurring schedule like every hour or the 1st of every month.
Using Process Builder, Flow, or Apex you can have more granular control when a Mass Action Configuration runs by calling an Apex action called ingeniously Run Mass Action.
For example, with Process Builder you could wait for certain record conditions to occur or listen for Platform Events before running a Mass Action Configuration. Or, with Flow you could have a support agent walk through screens and when conditions right then run a Mass Action Configuration.
First, create a Mass Action Configuration record.
Second, create a process and define one of it's Immediate Actions
or Scheduled Actions
an Apex Action Type that calls the apex class labeled Run Mass Action
. It accepts one input variable, the Mass Action Configuration record's Salesforce ID.
Now anytime your process runs and meets your criteria then it will also run your Mass Action Configuration in the background.
First, create a Mass Action Configuration record.
Second, create a flow and drag the Apex element named dca_mass_action__MA_RunConfigInvocable
to the canvas. It accepts one input variable, the Mass Action Configuration record's ID. It returns one output variable, the backaground apex job ID.
Now anytime your flow runs and meets your criteria then it will also run your Mass Action Configuration in the background.
First, create a Mass Action Configuration record.
Second, call the dca_mass_action__MA_RunConfigInvocable
with a list of one or more requests. Each request will submit as a separate background apex job the Mass Action Configuration record.
dca_mass_action.MA_RunConfigInvocable.Request req = new dca_mass_action.MA_RunConfigInvocable.Request();
// specify one of `configId` or `configUniqueName` on the request
//req.configId = <your config id>;
//req.configUniqueName = <your config unique name>;
List<dca_mass_action.MA_RunConfigInvocable.Response> responses = dca_mass_action.MA_RunConfigInvocable.execute( new List<dca_mass_action.MA_RunConfigInvocable.Request>{ req } );
for ( dca_mass_action.MA_RunConfigInvocable.Response res : responses ) {
System.debug( res.jobId );
}
Home | About | Getting Started | Sponsor | Copyright © 2017-2023 Douglas C. Ayers. Terms of use.