How to create a Salesforce Scratch Org

Author - Webner
13.04.2021
|
0 Comments
||

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.

    Scratch

  • 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.
    Scratch
  • 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.
    sf
  • 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.
    Scratch
  • 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.
    sf2

    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
    workflow

  • 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
    ANALYTICS_Account_Manager_Reports.reportFolder-meta.xml
  • Remove <consumerKey> from ToolingApi connected app or any other connected app meta XML file. Also in ToolingApi change the URL from login.salesforce.com to test.salesforce.com
  • Change the url in remoteSiteSettings (CWB_mdapidetail1ea7.remoteSite-meta.xml ,
    <url>https://cs69.salesforce.com</url> , LayoutToolingApi.remoteSite-meta.xml ,
    <url>https://app-business-4778-dev-ed.visualforce.com</url> LayoutToolingTestApi.remoteSite-meta.xml) ,
    <url>https://app-business-4778-dev-ed.my.salesforce.com</url>
  • 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.
    sf3
  • 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.
Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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