Set Up Your Salesforce Environment
- 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.
Tasha and her team follow these steps to create a new Trailhead Playground.
- In any Hands-On Challenge, click the dropdown and choose Create a Trailhead Playground.
- After it has been created, use the Manage my hands-on orgs option from the same menu to edit its name, if desired.
- 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.
- From Setup, enter Dev Hub in the Quick Find box and select Dev Hub.
- To enable Dev Hub, click Enable. Don’t change any of the other options.
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 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.
- 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.
- To confirm that Salesforce CLI is installed, open VS Code and choose Terminal→New Terminal. It will look something like this:
- In the command prompt, enter:
If Tasha installed 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.
- Open VS Code and go to the Terminal in the Panel.
- 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
- 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.
- When prompted to “Allow Access” for Salesforce CLI, click the Allow button.
- 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.