A Step-By Step Guide To Salesforce Scratch Org Management

Salesforce scratch org management is a process of the Salesforce platform that allows developers to create and manage isolated Salesforce environments, called scratch orgs, for development and testing purposes.

A Step-By Step Guide To Salesforce Scratch Org Management
Table of contents

They are temporary, disposable environments that can be created on demand and can be customized to match the specific needs of a development project.

🐛
Developers can create multiple scratch orgs for different development tasks, such as testing new features or fixing bugs, without affecting other team members.

In the past, Salesforce development was typically carried out in sandboxes. Changes were moved using change sets or other metadata deployment tools.

Salesforce has however introduced a new development model, which includes scratch orgs. Some users are thus unsure about if they should be doing their development work in a sandbox or a scratch org.

To determine which one should be used when, it is crucial to know the differences between the two.

Scratch orgs

Sandboxes

They are erased after seven days.

They only erase when it refreshes.

They have no data or metadata.

They contain different levels of data and metadata.

They are a blank org.

They come from a ‘source org’ with some of its data.

When it comes to scratch orgs, they are typically managed using a combination of command line Interface (CLI) commands and metadata configuration files. For continuous integration and delivery and version control, they are enforced by SFDX.

Here are the main steps involved in managing scratch orgs:

Create a scratch org

Using the CLI, you can create a new scratch org and configure it with specific settings, features, and data.

Develop in the scratch org

Once the scratch org is created, you can use it to develop your Salesforce code, such as creating or modifying objects, fields, workflows, and other metadata.

Push metadata to the scratch org

After making changes to your local codebase, you can use the CLI to push the changes to the scratch org. This ensures that the scratch org reflects the latest changes.

Test and validate changes

With the changes pushed to the scratch org, you can test and validate the changes by running automated tests, manual tests, or using other validation methods.

Create a new scratch org

Once the scratch org has served its purpose, you can delete it and create a new one. This allows you to start fresh and ensures that you are always working with a clean development environment.

In essence, managing scratch orgs from a command-line is like playing Tetris with command-line blocks, it's fun but can get messy pretty quickly.

With that being said, managing Salesforce scratch orgs can present several challenges:

  • Managing scratch orgs using the CLI requires a good understanding of Salesforce CLI commands and metadata configuration files, which can be challenging for new users.
  • Setting up and configuring scratch orgs using the CLI can be a time-consuming process, especially when working on complex Salesforce projects that require multiple scratch orgs. For some products, it may take hours for a scratch org to spin up. This means that development is halted during this waiting period.
  • Configuring scratch orgs using the CLI is a manual process that requires users to enter commands and make configuration changes manually. This can be prone to errors and can make it challenging to ensure that all scratch orgs are set up consistently.
  • Managing scratch orgs using the CLI can be challenging, as it can be difficult to keep track of which changes have been made to which orgs.

However, what if there's a better way to manage your scratch orgs?

🚧
A way that feels more like playing Jenga than Tetris, where you can build up and tear down environments with ease.

With Hutte, a web UI to SFDX that enables visual Salesforce version control, Salesforce scratch org management becomes a labor-saving development workflow.

Hutte enables developers to easily create, modify, and delete scratch orgs as needed.

Hutte is truly one of the best tools that we use. Product owners, Salesforce solution architects, business analysts — anyone on our team can easily and visually accomplish the tasks that would otherwise take a lot of clicks, time, and coding.

Sebastian Lechner

Product Management Director of IPfolio
Clarivate

Source: Hutte

With that being said, let’s go through how to manage scratch orgs using Hutte.

Create Scratch Orgs In A Collaboration-Friendly Environment

You can create scratch orgs that can be accessed together as a team. Various users can create their scratch orgs using the “New scratch org” button.

You can choose a Git branch from which you want to create your environment, and you can name it.

🤝
Your scratch orgs will be listed in one place showing you a historic overview or snapshot of your projects, apps, and codebases created in Git. This is a helpful feature as you and your team ultimately want to contribute to each other’s work.

Without Hutte, you need to rely solely on CLI. With Hutte, you can:

  • Easily make changes to the latest state of your source
  • Implement the new feature
  • Ship it to Git
  • It will get integrated with Hutte.
If a developer has executed new features and submitted it to Git, instead of them manually having to tell the team that they have provisioned an environment, the team can simply view it on the scratch orgs dashboard.

They will tell the team which branch they added the features to. You can then find the branches by “New scratch orgs.” From there, you can create a scratch org from that branch. It will appear in your list of scratch orgs.

  • You won’t need to run the code locally
  • It won’t block your machine, and it won’t block you
  • It will run asynchronously on Hutte’s infrastructure.
☝️
When your scratch org is ready, you won’t have to worry about user creation or any manual steps to build the org. Once you have logged into the scratch org, you can play around with it without affecting other users’ data.

Hutte essentially empowers users to easily manage and pick their own environments.

Pick A Scratch Org From The Pool

Hutte has a pool of orgs pre-created for you, so you don't need to wait, as you can spin them up visually. Picking a scratch org from the pool speeds up the process even further when you need an environment from the latest state of your source.

You can “Take from pool,” enter the name of the pool you want to claim, and it will appear in your pool.

You can dimensionate your pool by going to the “Settings.” As an addition, you can decide how big the pool is and what the duration of the pool will be.

Hutte Offers Easier Sandboxes

Without Hutte, you need to follow these steps for sandboxes:

  • Install the necessary CLI tools
  • Create a new sandbox
  • Configure the sandbox
  • Use the sandbox
  • Clean up the sandbox.
🤯
With Hutte, you can visually have access to the latest sandboxes in your org without CLI or coding knowledge. You can also create your own sandboxes. You will soon be able to refresh sandboxes and bring them to the latest version of the code. 

There is also a “Features” tab that enables you to collaborate on changes within sandboxes, like with scratch orgs.

Hutte’s Jira Plugin

If you use Jira, there will be a work item for it. Hutte’s Jira plugin will then find scratch orgs that reference the same name as your work item (or issue).

You, as a product manager, can then leave a comment to the developer that worked on the scratch org you selected. This enables collaboration without any interference or overriding of work already done by a developer.

This plugin is still very new, so watch this space for more updates.

Scratch Org Management Made Easy

Even though scratch orgs are intended to be workspaces where individuals can explore and test features in isolation, when you work together, you can conquer challenges. Obstacles like configuration management, data management, and juggling multiple scratch orgs become more streamlined.

💡
Plus, teaming up helps you share code, manage dependencies, and optimize your workflows for maximum productivity and efficiency. 

So, consider utilizing Hutte, work together, and watch your Salesforce development efforts skyrocket with better outcomes and top-notch code quality.