Skip to main content

How to find track history enabled fields in your Salesforce instance


Field history tracking is a Salesforce feature that allows tracking of changes to object field changes over time. In today's post well cover:

  1. What is field track history in Salesforce
  2. Changes to field change history data retention coming in the Spring 19 release
  3. How to use SOQL and workbench to find fields with track history enabled

What is Field Track History?

Salesforce comes out of the box with field change tracking functionality for standard and custom object fields. When enabled, up to 20 fields can have changes tracked for most objects in Salesforce. The field value changes are stored in object "history" tables and can be viewed from the Object History related list on an object record, from history reports, weekly data exports, data loader and API access.

Changes to field tracking history data in Spring 19

The Spring 19 release, which goes live in February 2019, brings the enforcement of Salesforce’s policy for retaining field tracked change data for orgs created after June 1, 2011.  If you org was created after this date and, tracked change history data will be available in your instance for:
  • 18 months via the User Interface
  • 24 months via API / Data Loader
After 24 months Salesforce will schedule deletion of track field history change data that meets this criteria. For more info see the Spring 19 release notes.

My Org is affected by this change

So you’ve determined that your Salesforce instance is affected by the Spring 19 change. The next step is to assess which the object fields are currently being tracked for changes. 

Before we continue, you should note that we are looking at field change history in this post and not Chatter feed tracking, which is separate.



Finding tracked history fields in Salesforce

There are a few options for identifying objects with track history enabled in your Salesforce instance:
  1. Manually review each object in Salesforce
  2. Open Dataloader (or your dataloader of choice) to see History objects
  3. Use SOQL
Being an awesome admin means you're all about efficiency. With lots to do, manually reviewing objects could take a long time. So we are going to use SOQL to easily identify the fields enabled for track history. Let’s dive in.

So what is SOQL?

Wait a minute. What's this SQOL you speak of? SOQL stands for Salesforce Object Query Language, and allows admins and developers to run queries on salesforce data and metadata. You can find out more on SOQL at https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm and in this trailhead module - https://trailhead.salesforce.com/en/content/learn/modules/apex_database/apex_database_soql.

With SOQL, you can access two objects called EntityDefinition and FieldDefinition, which store metadata about sobjects and their related fields. We'll query these objects to identify if track history is enabled on a field without having to manually review each object in Salesforce.


Even if you've never used SOQL before, you can easily complete this task and let the platform do the hard work for you. Note that for this example I’m going to use Workbench. However you can also use the Developer Console in Salesforce if you prefer. You can also use your IDE / Data Loader of choice to export the results.

Viewing fields with Track History Enabled

  1. Open a web browser and go to https://developerforce.salesforce.com
  2. Select the instance type (Production or Sandbox), select an API version (or leave the default) and agree to the terms of use
  3. Click Login with Salesforce

    workbench login
  4. Log in to your salesforce org (unless already logged in)
  5. Go to Query > SOQL Query


View all tracked fields and the related object:
1) Copy and paste the following SOQL statement in the query window:


SELECT entitydefinition.developername, entitydefinition.qualifiedAPIname, QualifiedApiName, label, datatype, length, ExtraTypeInfo, precision FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName !=null and IsFieldHistoryTracked = true

2) Click Query


Sample output:


Workbench tracked field output


Note - The output includes object fields that salesforce enables track history on.




View tracked fields for specific objects
1) Copy and paste the following SOQL statement in the query window:

SELECT entitydefinition.developername, entitydefinition.qualifiedAPIname, QualifiedApiName, label, datatype, length, ExtraTypeInfo, precision FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName in ('Account','Contact','Lead','Task','Event', 'Opportunity','Contract') AND IsFieldHistoryTracked = true

2) Click Query


NOTE: Add or remove salesforce objects as required from the second SQOL statement  ('Account','Contact','Lead','Task','Event', 'Opportunity','Contract'). Just be sure to use the API name for an object (e.g. meeting__c for a custom object called meeting).


Export results to CSV file

In Workbench:
  1. Click the Bulk CSV option in View As

  2. Click Query

    Confirmation screen:
    Workbench bulk API job status
  
In Salesforce:
  1. Go to Your Name (or Setup Icon) > Setup
  2. Enter "Bulk data" in setup search
  3. Click Bulk Data Load Jobs under Monitor > Jobs 
  4. Click the Job Id
  5. Under Batches, click View Result

Results open as a CSV file for further analysis.

Within a few minutes you've got a complete list of fields with tracked history tracking enabled as well as the associated object and field parameters. Pretty sweet. The FieldDefinition object has a lot more information that you can get about fields in Salesforce but we’ll save that for another post.

Recap

  • Salesforce has functionality to track changes to fields
  • The Spring 19 release brings enforcement of the 18/24 month field history data retention policy
  • Awesome admin’s can use SOQL to quickly find all of the track field’s and the related objects that exist within a Salesforce org

Comments

Popular posts from this blog

Spring 18 & Summer 18 certifications due Dec 14, 2018

It’s the most wonderful time of the year Family, gifts, traditions, reflection, candles and a roaring fire place or a day at the beach. And what holiday season would complete without salesforce maintenance exams. Wait, what? With everything going on in the silly season that is the holidays don’t forget that Salesforce  certification maintenance exams for the spring 18 and summer 18 releases are due no later than December 14, 2018. Make sure that you continue to be recognized as a leading professional within the Salesforce community by completing the exams. Recap What : Salesforce certifications maintenance exams for spring 18 and summer 18 Releases When : December 14, 2018 How : Trailhead and Webassesor  Why : If you don’t complete the certification exams by the deadline, your certifications will lapse and you’ll have to resit the tests to be a certified salesforce professional

Add an image to a login flow

Login flows allow you to run automation or display  messages after a user successfully logs in to Salesforce. In this post, I'll show you how to add an image to a login flow in Salesforce using a URL in a screen flow. For this setup you'll need: Login flow Custom label HTML/CSS knowledge Let's get started. Create a custom label Go to Setup > Custom Labels Click New Enter a name for the label eg LoginFlow Image Enter LoginFlow as the category Enter the following HTML snippet then click Save   <img src="URL OF THE FILE TO DISPLAY alt=“file description”> Pro Tips Using a custom label allows for the image to be updated without changing the flow logic. Add CSS to style the image and any text you want to display. Create a screen flow Go to Setup In setup search enter flow Select Flows Click New > Screen flow Drag a screen element on to the canvas  Enter a name and description for the screen Add a text output component In the formula editor select flow > label