Newer Version Available

This content describes an older version of this product. View Latest

HistoryRetentionPolicy

Represents the policy for retaining field history data. By setting a policy, you can specify the number of months you want to maintain field history in Salesforce and the number of years that you want to retain field history in the archive.

This component is only available to users with the “RetainFieldHistory” permission.

Declarative Metadata File Suffix and Directory Location

Field history retention policies are defined as part of a standard or custom object. You can set field history retention policies for objects individually. See CustomObject for more information.

Version

Available in API version 31.0 and later.

Fields

Field Name Field Type Description
archiveAfterMonths int Required. The number of months that you want to keep field history data in Salesforce before archiving. You can set a minimum of 1 month and a maximum of 18 months. If you don’t set a number, the default is 18 months. (That is, Salesforce maintains data for 18 months before archiving.)
archiveRetentionYears int Required. The number of years that you want to retain data in the archive. You can set a minimum of zero years, and a maximum of 10 years. If no number is set, the default is 10 years.
description string A text description for the history retention.
gracePeriodDays int The number of days of extra time after the archiveAfterMonths period before the data is archived. The gracePeriodDays interval applies only to the first time that the data is archived; because all the data is copied the first time, the operation may take longer than subsequent times when only the data that changed since the last archival operation is copied. The gracePeriodDays provides extra time for the administrator to prepare the organization before the initial archive operation. You can set a minimum of zero days and a maximum of 10 days. If no number is set, the default is 1 day.

Declarative Metadata Sample Definition

This sample shows the definition of a history retention policy for a custom object:
1<?xml version="1.0" encoding="UTF-8"?>
2<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3   <historyRetentionPolicy>
4       <archiveAfterMonths>6</archiveAfterMonths>
5       <archiveRetentionYears>5</archiveRetentionYears>
6       <description>My field history retention</description>
7   </historyRetentionPolicy>
8
9...
10</CustomObject>