Use case:

  • Enable historical trending on some object (like Opportunity) in sandbox
  • Deploy to source control
  • Deploy to org from source

The metadata API states that if you deploy a CustomField with property <trackTrending>true</trackTrending>, that:

Indicates whether historical trending data is captured for the field (true) or not (false). An object is enabled for historical trending if this attribute is true for at least one field.

But this doesn't seem to work. Historical trending is not enabled on the target object.

1 Answer 1


With an assist by our DevOps tool vendor (Gearset), the following was ascertained:

  • If you deploy <trackTrending>true</trackTrending> for one of the fields which have history turned on as default when it is enabled for the object (e.g. Amount, Close Date, etc for Opportunity), then it does not turn historical trend reporting on in the target
  • If you deploy one of the non-default fields, then it does turn history trending on in the target
  • You can turn off the non-default fields by deploying false for them.
  • There doesn't appear to be any way to turn off trending - deploy false for all the fields does nothing to the default ones.
  • The metadata api returns <trackTrending>false</trackTrending> for all fields if history trending is turned off, including fields that can never have history trending turned on. But, if you turn history trending on for the object, then it removes those false lines from the fields which can't have it turned on. Not relevant, but curious.

Bottom line:

  • For OOTB objects, if you enable historical trend reporting in your source org, you must enable a non-default historical trending field (e.g. Foo__c) to get the target org to see the deployment.
  • Then, do a subsequent deployment on the non-default field to set <trackTrending>false</trackTrending> (or possibly delete the field - not tried).
  • 2
    enableTracking/enableHistory are some of the flakiest things in DX. I spoke to Wade about this, and I think they logged a bug or three regarding it.
    – sfdcfox
    May 20, 2018 at 4:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .