Batch job - enhancement in execution criteria
Execution Criteria result log records are meant for audit purposes and the Banks/FIs clear them on a regular basis. These execution criteria result log records filling up storage space in Salesforce Org as there is no mechanism, other than manual intervention, to delete such records in the system. Also, storage space is a concern in terms of the cost of space.
Now, you can execute CleanupExecutionCriteriaResultsJob to delete the execution criteria result records ( as these records are filling up the space) from the database. These deleted records are stored in Salesforce's recycle bin and you can restore those as well.
With this enhancement, you can define the age of the records that need to be deleted in the custom metadata type Batch_parameters, which is used to configure values of batch parameters. The age parameter determines how old the records should be before deletion.
Prerequisites
None.
Steps
To configure and execute CleanupExecutionCriteriaResultsJob:
Log in to your Salesforce account.
Select (Setup), and then select Setup.
In the Quick Find box, search for Apex Classes and select it.
Select Schedule Apex and perform the following actions, and then select Save:
Note:All the fields are mandatory.
Field name Action Job Name Specify a unique name for the job to identify it Apex Class Search for CleanupExecutionCriteriaResultsJob and select it. Schedule Apex Execution Frequency Select a frequency based on your requirement. It can be Weekly or Monthly. Start Select a start date for the job End Select an end date for the job Preferred Start Time Select a time when you want to run the job Once the job is scheduled, you can view that on the Scheduled Jobs page (Go to the Quick Find box, search for Scheduled Jobs and select it.).
If you want to specify the age of the data to be deleted, perform the following steps:
In the Quick Find box, search for
Custom Metadata Types
and select it.Select Manage Records for the Label Batch Parameter.
Select Edit for the Label Age of ECR records for cleanup and specify the age of the data in the Parameter Value field.
Note:This value determines how old the records should be before deletion. The default value is 5 for the Parameter Value field.
To view the status of the job, go to the Quick Find box, search for Apex Jobs and select it.
Note:The job status can be Failed if the records are locked.
To override the configured age parameter, the parameter can be passed to the class directly as below:
CleanupExecutionCriteriaResultsJob job = new CleanupExecutionCriteriaResultsJob(age of the record to be deleted);Batch.execute(job);