Release - November 22
Search…
⌃K

Deploy to a Sandbox

Learning Objectives

  • Get comfortable with CLI tools
  • Deploy a repo using MDAPI to a Salesforce org
  • Retrieve changes in an SF sandbox to a repo
  • Mechanisms to retrieve metadata from an org
  • Identifying the names of the component to be retrieved
  • Deploying the updated repo to a different org
Time to Complete : 45 Minutes

Steps

Setup

  1. 1.
    Fork the [email protected] repo to your GitHub account
Instructions on how to fork a repo are available at the below link https://docs.github.com/en/github/getting-started-with-github/fork-a-repo
  1. 1.
    Clone the forked repo from your GitHub account to a local repo
  2. 2.
    Open up the project in VS Code
  3. 3.
    Authenticate your SFDX CLI in the terminal to one of the trailhead org's created in the prerequisites

Deploy the repo to the authenticated org

  • Use sfdx force:mdapi:deploy in your terminal (use the -h flag to understand usage) to deploy this code base to the org
    sfdx force:mdapi:deploy -u <playground-1> -d mdapi -w 30
Did it fail? you will need to delete the jsconfig.json file in your mdapi/lwc/jsconfig.json

Assign the dreamhouse permission set to the default user using sfdx force:user:permset:assign

sfdx force:user:permset:assign -u <playground-1> -n dreamhouse

Import the data using sfdx force:data:tree:import

sfdx force:data:tree:import -p ./data/sample-data-plan.json -u <playground-1>

Make the following changes your org

  • Set Compliance Categorization as PII to all fields in Property__c object
    • Open Playground
    • Setup --> Object Manager --> Search Property in Object finder--> Fields & Relationships --> Address --> Edit --> set Compliance Categorization as PII
    • Follow this step in ALL the fields in Property object
  • Create a field in property object and add it to layout
    • Setup --> Object Manager --> Search Property in Object finder--> Fields & Relationships --> New --> with below details
    Field
    Value
    Data type
    Picklist (Multi-Select)
    Label
    Features
    Values
    Air conditioning
    Carport/Garage
    Garden/Backyard
    Solar panels
    Deck/Pergola Dishwasher
    Swimming pool
    Built-in barbecue
    Water feature
    Garden gnomes
    Restrict picklist
    ✔️
    Visible Lines
    4
    • Edit property layout and add features field to information section under tags field
    • Edit dreamhouse permissionset and add feature field with edit access
  • Add daysOnMarket component to property explorer
    • Open Dreamhouse app in App launcher
    • Open Property Explorer tab
    • Click Setup gear Icon --> Edit page --> search daysOnMarket in component finder --> add the component to right side panel
    • Save the changes and click back
  • Create a new Apex class
    • Open Developer Console
    • File --> New --> Apex class --> ContactController --> ok --> use below code and save the class
      public class ContactController {
      @AuraEnabled
      public static List<contact> getContacts(string searchKey){
      string key = '%'+ searchKey +'%' ;
      return [SELECT Id,Name FROM Contact WHERE Name LIKE :key ORDER BY Name LIMIT 50];
      }
      }

Retrieve all the changes from the org

sfdx force:mdapi:retrieve -w 30 -u <playground-1> -r <temp-directory> -k <path-to-your-new-package.xml>

Redeploy your changes to the other trailhead org

  • Utlize sfdx force:mdapi:deploy in your terminal (The reference to documentation is attached or use the -h flag to understand usage) to deploy this code base to the org.
sfdx force:mdapi:deploy -u <playground-2> -d mdapi -w 30

Assign the dreamhouse permission set to the default user using sfdx force:user:permset:assign

sfdx force:user:permset:assign -u <playground-2> -n dreamhouse

Import the data using sfdx force:data:tree:import

sfdx force:data:tree:import -p ./data/sample-data-plan.json -u playground-2
Once the metadata is successfully deployed your work into your , commit and push your changes to your [email protected] repo.

Recap

Awesome! You have completed your first challenge. Though this is cumbersome, this is typically easier than redoing your changes in the next environments (especially when you have many). In our subsequent challenges, we will look at how to make these practices simpler.