When you need to apply a business policy to a large number of existing records you can start a batch job. 

Batch jobs run in the background and are able to process very large numbers of records, up to the limits allowed by Salesforce.

Submitting a batch job

To start a batch job click the 'Run Batch Job' button on the policy detail page:

Note: the button is greyed out when the selected version is a draft -- but you can run a batch against any other version, including older (inactive) ones.

A dialog appears that allows you to specify the parameters of the batch job. You can enter the following:

  • Where Clause
    • This (optionally) allows you to select a subset of records to which the policy will be applied.
      For example, Industry = ’Insurance’ will select only records with the Industry field set to 'Insurance'.
    • The format of the where clause is defined by the SOQL language, see here for details.
    • To validate the syntax of your WHERE clause, press the Tab key or click outside of the text box.
      If the syntax is correct, this will show the number of records that match the condition. Otherwise, it will show an error message.
  • Send email on completion
    Whether you would like to receive an email on completion of the batch, only on failure, or not at all.
    This email will go to the person running the batch.

  • Create execution record?
    Whether you would like to create Policy Execution Records for records processed as part of the batch
  • Batch Size

    • This specifies the number of records to process in one call to the Decisions on Demand server.

    • The default is 50 which works well for most cases.
      If you experience issues with governor limits you can reduce this to 25 or 10.
      If you need to speed up your batch processing you can try higher values -- the maximum is 2000.

Click 'Run' to launch the job. You will see a verification as follows:

Followed by a confirmation that the batch is running if you clicked 'OK'

Tracking progress of a batch job

To track progress of the job, click 'Run Batch Job' again:

If the job is still running, you can stop it by clicking the 'Stop' button.

Click the 'Refresh' icon to update the status, or check the 'Auto refresh' box to have the status updated automatically.

To view the underlying APEX job, go to Setup and look for 'Apex Jobs'. You will see an entry for the job you created in the list:

Note that jobs may complete quickly, in which case the status will shows as 'Completed'

If you requested an email on completion you will be notified of the final results. If you do not receive an email please verify that your Deliverability setting are set to 'All Email'

Checking the results of a batch job

You can check the results of a manual batch run in the Batch Invocation Records tab on the policy detail page (it is located below the policy tables):

Clicking on the invocation record number will show all the execution records for that specific invocation:

Running the same job again

Sometimes it is useful to run the same job multiple times -- for instance if you have changed the rules and want to make sure all records are updated.

To see a list of all previously run batch jobs, click the 'Run Batch Job' button again. Click the 'Run Again' button to (you guessed it...) run a job again with the same settings. If you no longer need the configuration, you can delete it by clicking the X on the right.