We are glad to announce that AnavClouds has achieved the Ridge Status (Silver Partner) with Salesforce.
better service existing ones

Introduction to Salesforce Scratch org

  • Posted By
  • January 26th, 2021
  • 0 Comment

Scratch Orgs are a new type of org that is applied for the Salesforce DX environment, acting as the capabilities of Salesforce DX environment. Salesforce DX is a set of tool that serves the purpose of improved collaboration and productivity among the developers. It helps to enhance the efficiency of the release cycle adding agility. It facilitates automated testing as well as continuous integration.

Salesforce DX offers the benefit in terms of source code residing in the version control system, shifting the source of truth from the org to the Version Control System. The scratch org acts as a temporary org for you that is source-driven as well for the source code and metadata, The scratch org supports the development and testing of your application. The hub used by the scratch org is the Developer Hub. 

What is a Developer Hub? 

The Developer Hub is the main org that creates and manages your scratch org. It becomes possible to enable the Developer Hub for a paid org in Salesforce, as it is always a best practice to avoid working using the production org. It also lets you to create and manage second-generation packages as well as enable you to use the Einstein features. The best part is that Developer Hub is available both for the Classic and Lightning environments. 

This Developer Hub is available in the Salesforce editions such as Developer, Enterprise, Unlimited and Performance editions. However, the scratch org is not available in the Performance editions but in the Group edition but is available in the other three editions. You can enable the Developer Hub in the org, while referring to this link. Salesforce also offers a free license – the Salesforce Limited Access license for the users to use the scratch org. 

The scratch org can be opened in a browser with the Salesforce CLI, with no need to logging. 

How to Use the Salesforce CLI?

introduction-to-salesforce-scratch-org

(Credit: https://sfdx.in/what-is-sfdx/)

Salesforce CLI enables the developers to control the application lifecycle of the Salesforce mobile apps with the following steps:

  • The developers must install the CLI with the right link for Windows, that is appropriate for the environment and testing, There are different links for various OS. 
  • Next, make sure that you know the details of CLI
    Installation and also know how to access online help with the sfdx command, as shown in the below diagram.

introduction-to-salesforce-scratch-org

(Credit: https://trailhead.salesforce.com/en/content/learn/projects/quick-start-salesforce-dx/set-up-your-salesforce-dx-environment)

  • Enter the Developer Hub, taking the following steps:
  • Create the default org with the alias org. 

The developer uses the alias org to create the default org with the -d extension and opens the Salesforce login page. 

introduction-to-salesforce-scratch-org

(Credit: https://trailhead.salesforce.com/en/content/learn/projects/quick-start-salesforce-dx/set-up-your-salesforce-dx-environment)

Log into the Developer Hub using the credentials. 

  • Click on Allow. 

introduction-to-salesforce-scratch-org

(Credit: https://trailhead.salesforce.com/en/content/learn/projects/quick-start-salesforce-dx/set-up-your-salesforce-dx-environment)

  1. The credential of the Developer Hub is remembered by CLI and Developer org web page closes, allowing you to work.

There are pros and cons of using a scratch org or a sandbox. 

Scratch org Vs Sandboxes 

Scratch org starts empty, with no sample metadata that is associated with a standard org The differences between the scratch org over the sandboxes are as follows:

  • Creation method & purpose
  • Source-driven Development 
  • Shape 
  • Expiry 
  • Limitations 

Creation method and purpose 

A Scratch org is disposable in nature. There are many things which are not included in the scratch org such as:

  • Custom Objects, indexes, tabs and others. 
  • Profiles and permission sets
  • Picklist
  • Dashboard and reports
  • Sample data
  • Chatter feed
  • Sample data

On the other hand, sandboxes are copies of your Salesforce org, used for development, testing and training. But the sandbox is generally used for development, staging, unit testing, UAT and training the scratch orgs are best used for unit testing and continuous integration but with a higher level of granularity and control, the developer detects the issues at an early stage with this. 

Source-driven Development 

The added advantage with the scratch orgs is that the single source of truth resides in the source repository, for all that the developer is working on. Here the org maintenance is not dependent on any specific org. So, the changes can be pulled in and out with no such difficulty when the source repository is say Github. 

Shape 

The shape of a scratch org is determined by the parameters such as features, settings, licenses and limits. The org shape is created by the developer for imitating the baseline setup features, with one org active at a time and with no metadata. The benefit lies in the fact that the shape can be recreated with updates on changes made in settings, features, licenses, etc of the sources. org.  The developer can enable the shape of the scratch org for the shape but this is a beta feature. Those features in the scratch org which are not in the production environment can be enabled. 

Expiration 

The scratch org expires over a limited period of time say after 7 days unless set differently. But, the sandboxes do not have any such expiration date. 

Limitations 

If you use Salesforce CLI for only the sandboxes, then there is no requirement to enable the Developer Hub, unless the second-generation package (2GP) is created. The scratch org is used during the package generation process of the second-generation package. 

Conclusion

Scratch orgs are the new types of orgs for the Salesforce DX environment acting as capabilities for the Salesforce DX environment serving the purpose of improved productivity and collaboration among the developers. It enhances the efficiency of your release cycle with Agility. The scratch org is a configurable org for a short duration for your team that shifts the source of truth from the org to the version control system. It uses a hub called the Developer hub, which is available in both Classic and Lightning environment

The developer enables the Developer Hub with a specific link.  There are many differences between the scratch org and the sandbox environments in Salesforce, the primary difference is the short-term nature of the scratch org whereas the sandboxes are not. The benefit of the scratch org lies in the fact that the shape can be recreated by the developer with the scratch org, using updates for the changes in the features, licenses, settings and others. 

Leave a Reply

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

Schedule a call
Enable Seamless Customer Experiences