IS there a way in Apex to determine if a custom object has field tracking turned on? I dont care what the fields are I just need to know if the tracking is turned on


You can querry FieldDefinition table in Salesforce which will tell you which fields have history tracking enabled for which object.

eg. If I want to check what fields have history tracking enabled for Opportunity, my query will be

SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Opportunity' AND IsFieldHistoryTracked = true

And the above query will return me the lists of fields on Opportunity where History tracking is enabled.

Src: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_fielddefinition.htm

Note: Make sure your api version is 32 and Above as mentioned in above document FieldDefinition is only available after version 32.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.