How to Manage Scratch Org

How to Manage Scratch Org
On January 20, 2021, Posted by , In Salesforce

The scratch org recognised as a source-driven and disposable deployment of Salesforce code and metadata made for developers and automation. 

A scratch org is fully configurable, customizable, and moreover allows developers to work on different Salesforce editions with different features and preferences.

In order to work with scratch orgs, you have to enable the Developer Hub (Dev Hub) first in your production or business org. 

You have the option to use Salesforce Extensions for VS Code or Salesforce CLI to create scratch orgs. You have two options or ways of managing your scratch orgs: the first is using CLI commands or the second one is the Salesforce graphical interface.

You have the option to enable Dev Hub features in your Salesforce org so that you can create and manage scratch orgs, and also you can create and manage second-generation packages, and use Einstein features. 

Scratch orgs termed as disposable Salesforce orgs to support development and testing.

Also Check: Difference between Salesforce Customization and Configuration

To enable Dev Hub in an org

  • You have to login as System Administrator to your Developer Edition, trial, or production org (for customers), or your business org (for ISVs).
  • From Setup, type Dev Hub in the Quick Find box and select Dev Hub.
  • To enable Dev Hub, click on the toggle button named as Enable. Once you enable Dev Hub, then you can’t disable it.

Manage Scratch Orgs from Dev Hub

You have options to view and delete your scratch orgs and their associated requests got from the Dev Hub.

Active Scratch Orgs in Dev Hub represents the scratch orgs that are currently in use. 

  • Have access to or get into Dev Hub org as the System Administrator or as a user with the Salesforce DX permissions.
  • From the App Launcher, select Active Scratch Org in order to have a list of all active scratch orgs.
    If you want to view more details or information about a scratch org, then click on the link in the Number column.
  • Deletion of an active scratch org from the Active Scratch Org list view can be performed by choosing Delete from the dropdown.
    Deleting an active scratch org does not delete the request (ScratchOrgInfo) that created it, but it does free up a scratch org so that it doesn’t count against your allocations.
  • Select Scratch Org information from the App Launcher in order to view the requests that created the scratch orgs.
  • Click the link in the Number column in order to view more details about a request. The details of a scratch org request include whether it is active, expired, or deleted.
  • Choose Delete from the dropdown in order to delete the request that was used to create a scratch org.
    Deleting the request of Scratch Org information also deletes the active scratch org.

How to access the list of all scratch orgs created in the particular org by all developers.

  • Access the Dev Hub org as the System Administrator or as a user with the Salesforce DX permissions.
  • From the App Launcher, select Active Scratch Orgs then you can see a list of all active scratch orgs.
  • Click the link in the Number column in order to view more details about a scratch org.
  • Click the link in the Scratch Org Information column in order to view the request that was used to create the scratch org. 

Creating Scratch Org with CLI Command

Before you create a scratch org:

  • Set up your Salesforce DX project.
  • Authorize the Dev Hub org.
  • Create the scratch org definition file.

Ways to Create Scratch Orgs

  • Create a scratch org for development using a scratch org definition file, give the scratch org an alias, and indicate that this scratch org is the default. Use this command…

           sfdx force:org:create -s -f config/project-scratch-def.json -a testScratch-org

  • You should indicate the scratch org’s duration that will indicate when the scratch org expires (in days).

           sfdx force:org:create -f config/project-scratch-def.json –duration days 30 (you can specify the day).

If Scratch Org Creation is Successful

The command completes in less than a minute then you will get two items in the output: one is the org ID and the other is the username.

You can now open the scratch org. 

  • sfdx force:org:open

Some of the advantages listed below…

  • Increased Developer productivity.
  • Better and easier Team Collaboration.
  • DevOps Automation.

What is the difference between Scratch org and Sandbox org.?

  • Scratch Orgs are driven by source whereas Sandbox is a copy of production.
  • Scratch orgs are not permanent whereas Sandbox is permanent.
  • Scratch org does not include Production data whereas Sandbox includes production data.
  • Scratch orgs are temporary org and they have an expiration date when it gets created whereas Sandbox has no expiry date.
  • Shape: You can enable features in your scratch org that may not exist in your production environment, without contacting Salesforce support or buying extra licenses. Want to try out multi-currency? Use Person Accounts? Build an Einstein Bot? You can do all those things and more just by adding lines to the configuration file.
  • Source Driven Development: If you’re used to developing in standard developer sandboxes, then you may have experienced a situation where your development environment got really involved. Perhaps you were working on a couple of new features; one was ready to go, but you found a serious issue with the second one late in the day and it further stopped you from releasing the good information or stuff. Scratch orgs, used properly, will free you from this.
  • Testing: You get a very high level of granularity and control about where and when you do your testing. You can test a single issue, a feature branch, pre-merge, post-merge; wherever makes the most sense for your particular use case. There is no need to wait until stuff gets back into QA (Quality Assurance).

 

Contact Us
AwsQuality helps businesses gain competitive edge with solutions on Salesforce cloud and mobile technologies with Offices Noida India, Louisiana focused customers are in the UK, US, Asia, South America and Australia.

Comments are closed.