The retention date calculation is done periodically using a batch apex class. The batch apex sequences through all the active retention policies, select applicable business objects using the filters, compute the retention date and update the object.

An activity history record is written to the agreement with the policy information. The process terminates on two conditions- when either there are no more business objects to process, or all the policies have been applied. The process is scheduled using the RetentionDateCalcJobScheduler Apex scheduler class. Due to governor limits, each policy processes a maximum of 5000 records during each invocation.

To calculate a retention date

A Retention Policy must have been created.

  1. Click Setup > Develop > Apex Classes > Schedule Apex.
  2. Enter the following information to configure the job parameters.
    1. Job Name: Retention Calc Job
    2. Apex Class: RetentionDateCalcJobScheduler
    3. Frequency: Specify how often the Apex class is to run:
      For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).
      For Monthly—specify either the date the job is to run or the day (such as the second Saturday of every month.)
  3. Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job only runs once.

  4. Specify a preferred start time. The exact time the job starts depends on service availability.
  5. Click Save.

After you have done the job of calculating a retention date, you can monitor the progress of the job on the All Scheduled Jobs page.

Once the job has completed, you can see specifics about the job (such as whether it passed or failed, how long it took to process, the number of records process, and so on) on the Apex Jobs page.