Set Up Your Environment
Enable Developer Hub (Dev Hub)
Now that you have your Trailhead Playground open, enable Dev Hub. The Dev Hub feature allows you to create and manage scratch orgs: the Salesforce environments where you develop the DreamHouse Realty’s app. An org with the Dev Hub feature enabled is often referred to as a Dev Hub org.
- From Setup, enter
devin the Quick Find box, then click Dev Hub. Ensure that Enable Dev Hub and Enable Unlocked Packages are enabled.
Install the DreamHouse Sample App
In this project, Chan and Maria are developing new features for DreamHouse Realty’s existing app. Let’s start by adding the DreamHouse Realty unmanaged package into your Trailhead Playground. It adds metadata and customizations that make your hands-on work more realistic and meaningful. You also use this package and playground when it’s time to complete the hands-on challenge.
Install the package.
- Launch your Trailhead Playground by scrolling to the bottom of this page and clicking Launch.
- If you see a tab in your org labeled "Install a Package", great. Follow the steps below.
- Click the Install a Package tab.
04t3s000002qbLHinto the field.
- Click Install.
- Select Install for Admins Only, then click Install.
- If you don’t see the Playground Starter app, copy https://login.salesforce.com/packaging/installPackage.apexp?p0=04t3s000002qbLH and check out Install a Package or App to Complete a Trailhead Challenge on Trailhead Help.
- When your package is finished installing, you see a confirmation page and get an email to the address associated with your playground.
Download the exercise files that you use in later steps.
- From Setup, enter
staticin the Quick Find box, then click Static Resources.
- Click Exercise Files, then click View file, save the file to your computer, and unzip it.
Assign the DreamHouse permission set.
- From Setup, enter
permin the Quick Find box, then click Permission Sets.
- Click DreamHouse, Manage Assignments, then Add Assignments.
- Select the checkbox next to your user’s name, click Assign, then click Done.
Create some sample data that we use to populate scratch orgs in later steps.
- Click to open the App Launcher, then click DreamHouse.
- Click Data Import then Initialize Sample Data. You should see a message like: Successfully imported 12 properties and 8 brokers.
- Click OK.
- Click the Properties tab and the Brokers tab to review the sample data.
Install and Update the Salesforce CLI
Use the Salesforce CLI to control the full application lifecycle of your Salesforce apps. With it you can easily create environments for development and testing, synchronize source code between your orgs and source control, and execute tests.
- Install the CLI from https://developer.salesforce.com/tools/sfdxcli.
- Confirm the CLI is properly installed by running the following command from the command line.
sfdx updateYou should see output like
sfdx-cli: Updating CLI....
Great, now let’s use the Salesforce CLI to finish setting up our environment.
Authorize Dev Hub Org with the Salesforce CLI
The Dev Hub org allows you to create, delete, and manage your scratch orgs. You can also authorize other existing orgs, such as sandbox or packaging orgs, to provide more flexibility when using CLI commands. For example, after developing and testing an application using scratch orgs, you can deploy the changes to a centralized sandbox. Or you can export a subset of data from an existing production org and import it into a scratch org for testing purposes.
- Authorize your Dev Hub org.
sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub
- Your browser opens a Salesforce login page. Enter your credentials for your Dev Hub org.
- If prompted, click Allow to allow Salesforce CLI to perform actions against your org, such as create scratch orgs or retrieve and deploy metadata..
- Switch back to your command prompt to confirm your Dev Hub org was authorized. You should see output like
Successfully authorized <username> with org ID <orgid>.
- Display a list of all authorized orgs. You should see an entry listed with alias
- Use this Dev Hub as the default for all Salesforce DX projects on this computer so that you don’t have to specify the
--targetdevhubusername | -vCLI argument for each command.
sfdx force:config:set defaultdevhubusername=DevHub --global
Well done. Click Verify Step to ensure the package was installed and some sample data was created in your Dev Hub org. Continue to the next step to create the Salesforce DX project for developing DreamHouse Realty’s app’s new features.