function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GenoudGenoud 

Enable History Tracking on Account Object while deploying a package with Metadata API

Hello everyone,

I'm trying to deploy a package which contains Custom fields added on Account standard object with History tracking enabled. The deployment fails with the error 
The entity: Account does not have history tracking enabled
I enabled the history tracking on the account object definition and it is not working. 
<enableHistory>true</enableHistory>
can someone help me understand what is going on?

Thanks 
Best Answer chosen by Genoud
SandhyaSandhya (Salesforce Developers) 
Hi,

There is a workaround suggested in below links.
a) Strip down Enable History Tags from Scratch org metadata and add them when deploying to sandboxes.
b) Enable History tracking manually before pushing the code to the scratch org.
I would suggest you refer below links for similar discussion.

https://salesforce.stackexchange.com/questions/188779/how-to-enable-account-history-tracking-in-scratch-org
 
https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F93A000000HTp1&fId=0D53A00003BauKc
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 

 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

There is a workaround suggested in below links.
a) Strip down Enable History Tags from Scratch org metadata and add them when deploying to sandboxes.
b) Enable History tracking manually before pushing the code to the scratch org.
I would suggest you refer below links for similar discussion.

https://salesforce.stackexchange.com/questions/188779/how-to-enable-account-history-tracking-in-scratch-org
 
https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F93A000000HTp1&fId=0D53A00003BauKc
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 

 
This was selected as the best answer
Shai FisherShai Fisher
You can enable history for objects by ant:
Strip anything from the object xml except enableHistory:
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <enableHistory>true</enableHistory>
</CustomObject>
(In some cases you need to add: <recordTypeTrackFeedHistory>true</recordTypeTrackFeedHistory>)

Then, deploy the original files, including tracking history fields.
 
cduncancduncan
You can enable Account History Tracking for new scratch orgs in your scratch org definition file using the "enableAccountHistoryTracking" flag under "accountSettings" which is under "settings". For example, the following scratch org definition file enables history tracking for Accounts, Contacts, Leads, and Opportunities:
{
  "orgName": "Test Org",
  "edition": "Developer",
  "settings": {
    "accountSettings": {
      "enableAccountHistoryTracking": true,
      "enableContactHistoryTracking": true
    },
    "leadConfigSettings": {
      "doesTrackHistory": true
    },
    "opportunitySettings": {
      "enableOpportunityFieldHistoryTracking": true
    }
  }
}

Source: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_accountsettings.htm