[SalesForce] What are the correct steps to create Scratch Orgs with custom objects

I am trying to create a scratch org based on existing DEV sandbox.
The problem is that I get a bunch of errors when trying to push the code into the scratch org:

Invalid type: Quote (13:9)
Invalid type: QuoteDocument (99:13)
DML requires SObject or SObject list type: QuoteDocument (101:17)

Theres also errors about custom objects and Apex classes.

So basically the scratch org doesn't have any information about any of the objects that I am working with.

The steps that I did to create my DX project from DEV sandbox environment:

1.Created a SFDX project

2.Created a package.xml of my existing DEV sandbox

3.Retrieved the data with package.xml

4.Initialized a git and committed all the files

5.Created a scratch org

6.Tried to push the code into the scratch org

In some cases I see that people need to do some conversion from metadataformat into source format. Is that what I am missing here?

I tried to do that but it only creates a similar kind of a project that I already did with SFDX: Create project command from Command palette in Visual studio code.

I just cannot find a simple example anywhere where somebody would show how to make a scratch org based on an existing Sandbox org with custom objects and fields.

Some guides say that I should use a scratch-org-definition file to create the scratch orgs shape but I cannot find any example how to include custom object info there..

What am I missing?

Best Answer

Ok I finally found a solution.

This was an annoying problem since the error message that you get back is quite misleading IMO. The problem is not with your custom objects, or atleast not in my case. The issue was that you need to enable Quotes for your scratch org and this I did not know.

So for anyone who is facing same kind of issues:

Make sure that you have correct configurations in your project-scratch-def.json file!!

All it took was me to add

  "settings": {
    "orgPreferenceSettings": {
      "s1DesktopEnabled": true
    },
    "quoteSettings": {
      "enableQuote" : true
    }
  }

to the configuration and all the errors went away. Also the ones complaining about those custom objects and Apex classes!

You can also enable Quotes manually in the scratch org by going Setup -> Quote Settings and clicking Enable

Related Topic