How to Control Field History Tracking
CopyStorm supports the tracking of nearly all field changes by checking the “Track Field History” box on the Advanced tab. When field history is enabled, default behavior is to track updates to EVERY field in EVERY table except for a handful of Salesforce auditing fields.
If the default behavior captures more data than your organization prefers, this article explains how to limit what is tracked.
Background
Fine control over field tracking is managed by a configuration file named FieldHistoryRecordFactory.xml. The file can be placed in either the “config” subdirectory of the CopyStorm installation or in the directory indicated in the CopyStorm configuration file. The built-in configuration file has rules excluding field tracking for a number of Salesforce audit fields and all formula columns.
It looks like:
<FieldHistoryRecordFactory> <IncludeFormulas status="false" /> <ExcludeField field="SystemModStamp" /> <ExcludeField field="LastModifiedDate" /> <ExcludeField field="LastModifiedById" /> <ExcludeField field="CreatedDate" /> <ExcludeField field="CreatedById" /> <ExcludeField field="LoginTime" /> <ExcludeField field="LastViewedDate" /> <ExcludeField field="LastReferencedDate" /> </FieldHistoryRecordFactory>
If you create your own configuration file, model it after the built-in file without repeating any of the built-in rules.
Like CopyStorm table selection, there are two basic approaches to controlling which fields are tracked:
- Telling CopyStorm which fields should be tracked.
- Telling CopyStorm which fields should NOT be tracked.
If CopyStorm is told which fields to track the rules indicating which fields should NOT be tracked are ignored and only fields CopyStorm is explicitly told to track will be included.
Include Specific Tables
To only track field history on specific tables, include the IncludeTable configuration directive.
The following FieldHistoryRecordFactory.xml will limit field history to the Account, Contact, and MyCustomObject__c tables:
<FieldHistoryRecordFactory> <IncludeTable table="Account" /> <IncludeTable table="Contact" /> <IncludeTable table="MyCustomObject__c" /> </FieldHistoryRecordFactory>
Exclude Specific Tables
To track fields in all tables EXCEPT for a few then use the ExcludeTable configuration directive.
The following FieldHistoryRecordFactory.xml will exclude ApexPages, ApexTriggers, and MyCustomObject__c from field history tracking:
<FieldHistoryRecordFactory> <ExcludeTable table="ApexPages" /> <ExcludeTable table="ApexTriggers" /> <ExcludeTable table="MyCustomObject__c" /> </FieldHistoryRecordFactory>
Include Specific Fields in a Table
The following FieldHistoryRecordFactory.xml will cause CopyStorm to only track the “Name” field on “Account” and the “FirstName”/”LastName” fields on “Contact”:
<FieldHistoryRecordFactory> <IncludeField table="Account" field="Name" /> <IncludeField table="Contact" field="FirstName" /> <IncludeField table="Contact" field="LastName" /> </FieldHistoryRecordFactory>
Exclude Specific Fields in a Table
The following FieldHistoryRecordFactory.xml will cause CopyStorm to not track the “WebSite” field on “Account”, and to not track the “Age”/”Birthday” fields on “Contact”:
<FieldHistoryRecordFactory> <ExcludeField table="Account" field="WebSite" /> <ExcludeField table="Contact" field="Age" /> <ExcludeField table="Contact" field="Birthday" /> </FieldHistoryRecordFactory>
Track Formula Value Changes
Default CopyStorm behavior is to not track changes to formula column values. The following FieldHistoryRecordFactory.xml will enable formula value history tracking:
<FieldHistoryRecordFactory> <IncludeFormulas status="true" /> </FieldHistoryRecordFactory>