[SalesForce] Apex: Is there a way to Identify if history tracking is enabled on the field or not

I tried Object.Field.getDescribe(); But, it doesn't have a parameter to identify if history tracking is enabled for a field or not. Is there any other way to identify all fields on my custom object with field history tracking enabled?

I have a custom object Steps__c [track history enabled] with 10 different fields out of which 2 fields "Status__c" and "Task_Status__c" have field history tracking enabled. I need a Vf page to show me only fields on Steps__c with history tracking enabled. Basically – show only Status__c and Task_Status__c in a selectList.

Best Answer

Since Winter '16 this can be achieved using the IsFieldHistoryTracked field on FieldDefinition.

To get all tracked fields on Steps__c you can use:

SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Steps__c' AND IsFieldHistoryTracked = true
Related Topic