Start tracking your progress
Trailhead Home
Trailhead Home

Set Up Your Salesforce Environment

Learning Objectives

  • Enable your Dev Hub.
  • Prepare your command line interface to use SFDX.
  • Authorize SFDX 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. They can get the ability to create scratch orgs by signing up for a Salesforce Developer Edition org and configuring that new org to have Dev Hub enabled. Dev Hub is a feature that lets you create and manage scratch orgs.

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

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 (aka SalesforceDX or SFDX) and CumulusCI, to her Dev Hub. After installing SFDX on her computer, she connects SFDX to Dev Hub—enabled in her Developer org—and this authorizes the use of scratch orgs.

Once SFDX 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 the 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: sfdx version

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

Authorize SFDX 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 SFDX 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: sfdx force:auth:web:login -a 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: sfdx force:org:open -u CCIDevHub

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

Resources