I went to put my newly create sfdx application onto a different scratch org. It seems as if the configuration of the 'set history tracking' is not saved when you pull. I verified if I changed the setting and the pulled nothing will get pulled down. Is there a way to get this into this configuration in the sfdx project?
I was able to overcome this issue by using the metadata api features of the SFDX command line. Here is my example use case:
- Account History Tracking needs to be enabled
- Create your scratch org
- Before pushing your repo into the new scratch org, run a pre-processor metadata api process. First, retrieve the metadata.
sfdx force:mdapi:retrieve -r ./scratch-mdapi-datamodel -k ./scratch-mdapi-datamodel/package.xml
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>Account</members> <name>CustomObject</name> </types> <version>42.0</version> </Package>
- Edit the object.xml file for which you need to enable history tracking. You can remove all of the unnecessary XML. Here is my example file for the Account.object file:
<?xml version="1.0" encoding="UTF-8"?> <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <enableHistory>true</enableHistory> </CustomObject>
- Deploy the contents of the object file back to the scratch org using the metadata deploy command:
sfdx force:mdapi:deploy -d scratch-mdapi-preload/unpackaged/ -w 30
The scratch org now has history tracking enabled for the Account and will accept your repository references for Account fields with history tracking enabled.
I actually put the contents of my /unpackaged/objects/Account.object into my repo and have scripted this process so that it automatically activates the feature and pushes the repo. Theoretically any other non-supported DX features could also be provisioned this way until they are officially supported by SFDX.
I have ran into this issue as well. It doesn't matter what is set to at the object level. It will not push that to a new ScratchOrg. If you have any fields with set to true you'll get an error that history tracking is not enabled at the object =.
I have had to remove the trackHistory from the field level in the hopes that when I do a metadata api push that it'll leave the value alone in the target environment.
I contacted SF support and got them to create this issue for me if you'd like to vote: https://success.salesforce.com/issues_view?id=a1p3A0000018BX2QAM