How to create a Salesforce Scratch Org

| By Webner

Scratch org is a disposable and source-driven deployment of Salesforce metadata and code which is made for developers (developing specific modules) and for automation that is continuous integration or continuous development. Scratch org is a configurable org/sandbox which allows the developers to emulate different Salesforce editions with different features and different preferences.

Steps to create scratch org with Visual Studio Code.

  • Open the code folder inside the DX folder in your VSCode.
  • From Command Palette (Ctrl+Shift+P), authorize the dev hub from your dev org.
  • Again from Command Palette, select the option to “Create a Default Scratch Org)
  • Select option-project-scratch-def.json. Below is a sample file.


  • Give an alias to your org.
  • Enter the number of days you want for your scratch org to be alive. (max is 30 days)
  • After the creation of Org, Open the org by pressing Ctrl+shift+P and type (Open Default Org). This will open the org in your default browser.
  • Reset the password for the user. This can be done as below.
  • After this search for, State and Country. Enable the country and state picklist. Click on each of the links in a serial manner given on each of the 4 points present on State and Country/Territory Picklists.
  • Select the United States in Default Country/Territory picklist and click on save. After that click on the second option Scan Now and you will receive an email upon its completion and then click on the third option Convert now.
  • After Clicking on Convert Now select United states in Change to picklist and click on Save to Changelist/Scan to Complete and then click on next.

    Then click on next again when on the state change list page as there would not be anything to be changed. On the next page click on Finish and Enable

  • Change this value in Account.workflow-meta.xml with the new user created in your scratch org. Change the value of <sharedTo> in ANALYTICS_Management_Dashboards.dashboardFolder-meta.xml
  • Remove <consumerKey> from ToolingApi connected app or any other connected app meta XML file. Also in ToolingApi change the URL from to
  • Change the url in remoteSiteSettings (CWB_mdapidetail1ea7.remoteSite-meta.xml ,
    <url></url> , LayoutToolingApi.remoteSite-meta.xml ,
    <url></url> LayoutToolingTestApi.remoteSite-meta.xml) ,
  • Change in this file also <endpoint> Layout_Tooling_Api.namedCredential-meta.xml
  • In these above URLs, cs69 is the instance of your scratch org and the other URLs are instance URLs for visualforce page and instance URL. This data can be fetched by using the command palette and selecting “Display Org Details for Default Org” as below.
  • Search for Process Automation Settings in the setup in the browser and then select user.
  • Push the code to the org.
  • Make changes in any of the components or add a new component and again push the code to your org.

Leave a Reply

Your email address will not be published. Required fields are marked *