Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Set Up Your Salesforce Environment

Learning Objectives

  • Enable your Dev Hub.
  • Prepare your command line interface to use Salesforce CLI.
  • Authorize Salesforce CLI to connect to your Dev Hub.

Tasha and her team need a way to build temporary Salesforce orgs so they can build and test new features. These are called scratch orgs.  Dev Hub is a feature that lets you create and manage scratch orgs. Normally, you would enable the Dev Hub in a developer org, but for the hands-on-challenge you will create a Trailhead Playground and enable Dev Hub there.

Create a New Trailhead Playground & Get User Credentials

In order to move ahead with their plans, Tasha and her team need to enable Dev Hub in a Trailhead Playground. 

Note

We recommend creating a new Trailhead Playground in this case rather than using an existing one. We’ll ask you to execute several configuration steps and installations in this org, and using a new one makes sure that existing configuration won’t affect your work on this trail.

Tasha and her team follow these steps to create a new Trailhead Playground.

  1. In any Hands-On Challenge, click the dropdown and choose Create a Trailhead Playground.
  2. After it has been created, use the Manage my hands-on orgs option from the same menu to edit its name, if desired.
  3. Get Playground credentials by following the steps in the Get Your Trailhead Playground Username and Password unit of the Trailhead Playground Management module (see link in the Resources section below).

Enable Dev Hub

Next, Tasha and her team follow these steps to enable Dev Hub.

  1. From Setup, enter Dev Hub in the Quick Find box and select Dev Hub.
  2. To enable Dev Hub, click Enable. Don’t change any of the other options.

Dev Hub Setup page

Prepare Command Line Interface

Now that Tasha’s ready to create and use scratch orgs, she needs to connect developer tools, such as Salesforce CLI and CumulusCI, to her Dev Hub. After installing Salesforce CLI on her computer, she connects it to Dev Hub—enabled in her Developer org—and this authorizes the use of scratch orgs.

Once Salesforce CLI is connected, Tasha needs to install CumulusCI to gain the automation framework for developing and testing Salesforce projects.

Install the Salesforce Command Line Interface

Tasha and her team follow these steps to install the interface.

  1. Navigate to the Salesforce CLI home and download the Salesforce CLI version for your operating system. Open the downloaded installation file and step through the installation with the default settings selected.
  2. To confirm that Salesforce CLI is installed, open VS Code and choose Terminal→New Terminal. It will look something like this:
    VS Code terminal with command prompt.
  3. In the command prompt, enter: sf version

If Tasha installed Salesforce CLI while VS Code was running, she may need to restart VS Code. She’ll know Salesforce CLI is installed because the command returns a single line in the Terminal panel that starts with @salesforce/cli and describes the version of Salesforce CLI that's installed.

Authorize Salesforce CLI to Connect to Dev Hub

Tasha and her team follow these steps to authorize Salesforce CLI access to a DevHub-enabled org. The authorization allows Salesforce CLI to securely store a token (a secure version of your username/password) along with the alias for the Salesforce org.

Suggestion: set the alias to CCIDevHub to match the example used throughout the Build Applications with CumulusCI trail. It's much easier to remember than your unique Trailhead Playground username.

  1. Open VS Code and go to the Terminal in the Panel.
  2. Type this web login flow command to log in and set an alias name for the org, such as CCIDevHub: sf org login web --alias CCIDevHub
  3. This will open a browser to the Salesforce login page. Log in using the username and password for the Trailhead Playground org in which you enabled Dev Hub.
  4. When prompted to “Allow Access” for Salesforce CLI, click the Allow button.
  5. Back in VS Code, verify you can now log into the org by typing this command: sf org open --target-org CCIDevHub

If successful, a browser window opens to the org's Setup page. Tasha can now work in the org using Salesforce CLI commands, so she can close the browser window at any time.

Resources

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback