6

Trying to push the source code to a scratch org I get the following error:

The entity: Opportunity does not have history tracking enabled (998:13)

But there is no option to specify on the scratch org definition file to enable the field history on opportunities. The only available option is to turn the history on for contracts.

Is there a workaround for this?

6

I've logged that bug with the DX team. The solution (for now) is to have an src directory in mdapi format, deploy the "history tracking" flag on the CustomObject first, and then deploy the fields afterwards.

sfdx force:mdapi:deploy -d src -w 10
sfdx force:source:push

Your src folder would be a traditional package:

src/package.xml

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Opportunity</members>
        <name>CustomObject</name>
    </types>
    <version>42.0</version>
</Package>

src/objects/Opportunity.object

<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <enableHistory>true</enableHistory>
</CustomObject>

Most of the fields are not necessary for standard objects, but be aware you have to specify things like label, fullName, pluralLabel, sharingModel, etc for custom objects.

4
  • Hey, do you have, perhaps, an issue number or link for this bug? It is something I'd like too to keep track of. – Renato Oliveira Jun 29 '18 at 20:01
  • 1
    @RenatoOliveira I spoke with Wade about it, he said he'd look in to it, but I don't have a number off the top of my head. It may be related to this issue, but the description doesn't match the current problem. I'll ask Wade if there was a Known Issue for this. – sfdcfox Jun 29 '18 at 20:05
  • @sfdxfox actually, that seems pretty much what I described. Except that I've faced the issue from steps 4 to 7. In my situation I got the field history tracking already enabled in production (4), and then pulled (5) the source and tried to push to a scratch org (6 and 7). – Renato Oliveira Jun 29 '18 at 20:11
  • 1
    @RenatoOliveira Oh, glad I could help, then. That was one of our showstoppers until I figured out this handy workaround (we since ran in to other issues, but at least I fixed this). – sfdcfox Jun 29 '18 at 20:19

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.