Erfassen Sie Ihre Fortschritte
Trailhead-Startseite
Trailhead-Startseite

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.

  1. From Setup, enter dev in 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.

  1. Launch your Trailhead Playground by scrolling to the bottom of this page and clicking Launch.
  2. If you see a tab in your org labeled "Install a Package", great. Follow the steps below.
    1. Click the Install a Package tab.
    2. Paste 04t3s000002qbLH into the field.
    3. Click Install.
    4. Select Install for Admins Only, then click Install.
  3. 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.
  4. 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.

  1. From Setup, enter static in the Quick Find box, then click Static Resources.
  2. Click Exercise Files, then click View file, save the file to your computer, and unzip it.

Assign the DreamHouse permission set.

  1. From Setup, enter perm in the Quick Find box, then click Permission Sets.
  2. Click DreamHouse, Manage Assignments, then Add Assignments.
  3. 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.

  1. Click App Launcher to open the App Launcher, then click DreamHouse.
  2. Click Data Import then Initialize Sample Data. You should see a message like: Successfully imported 12 properties and 8 brokers.
  3. Click OK.
  4. 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. 

  1. Install the CLI from https://developer.salesforce.com/tools/sfdxcli.
  2. Confirm the CLI is properly installed by running the following command from the command line.
    sfdx update
    You 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.

  1. Authorize your Dev Hub org.
    sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub
  2. Your browser opens a Salesforce login page. Enter your credentials for your Dev Hub org.
  3. If prompted, click Allow to allow Salesforce CLI to perform actions against your org, such as create scratch orgs or retrieve and deploy metadata..
  4. 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>.
  5. Display a list of all authorized orgs. You should see an entry listed with alias DevHub.
    sfdx force:org:list
  6. 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 | -v CLI 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.

Resources