Over time your use of Decisions on Demand may generate many policy execution records. You may want to clean them out in order to save data storage space.


We have put together an unmanaged package that you can install in your org to automatically delete old records on a regular basis. Out of the box, the package allows you to schedule a job which will delete all execution records older than either 7 or 30 days. If you would like to keep records longer, see below under

Using a custom retention period for steps to create a job that keeps records for a custom number of days. 


To use the package:

  • Install the package from this link
    Note: if you are installing in a sandbox, you may need to edit the URL to replace 'login' by 'test'
  • Go to Setup->Custom Code->Apex classes
    Or Setup->Develop->Apex classes in Classic
  • Click Schedule Apex
  • Select one of these two classes:
    • DecsOnD_ScheduledExecRecordCleaner_7: cleans all execution records older than 7 days
    • DecsOnD_ScheduledExecRecordCleaner_30: cleans all execution records older than 30 days
  • Provide a name, and select an appropriate time to run the job, such as once a week on the weekend
  • Click Save


You can verify that the job is scheduled by going to Setup->Environment->Jobs->Scheduled Jobs to see the job is listed:



From this screen you can also manage or delete the job.


Using a custom retention period

To customize the retention period, you can either:

  • Create and schedule your own subclass of DecsOnD_ScheduledExecRecordCleaner
    Call the base class constructor with the number of days you want records to be preserved. For example, to keep records for 180 days, the class would look like this:
    public class CustomScheduledExecRecordCleaner  extends DecsOnD_ScheduledExecRecordCleaner implements Schedulable{
        public CustomScheduledExecRecordCleaner (){
            super(180);
        }
    }


    You can then schedule this class as described in the previous section
  • Instantiate and schedule DecsOnD_ScheduledExecRecordCleaner directly
    You can embed a snippet like the following in your code, or execute it using Execute Anonymous:
    integer retentionPeriod = 180; // Customize to the desired number of days
    String cronExp = ...; // For format see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm#apex_System_System_schedule
    DecsOnD_ScheduledExecRecordCleaner sched = new DecsOnD_ScheduledExecRecordCleaner(retentionPeriod);
    String jobId = System.schedule('Delete execution reccords', cronExp, sched);