Release - November 22

Using Source Format

Learning Objectives

  • Why is source format necessary?
  • Converting from MDAPI to source format and vice versa
  • Utilizing source commands to retrieve and deploy
Time to Complete: 45 Minutes


Create a new source project using sfdx force:project:create command

  • Open new Visual Studio code window
  • Open a new folder where you wish to create the source format project
sfdx force:project:create -n dxatscale101-source -t empty

Convert the mdapi project used in 'Deploy to a Sandbox' challenge to source format

Utilise sfdx force:mdapi:convert command to convert the mdapi format into a local format known as 'source format'.This format makes working with metadata api modular and maintainable.
  • Go to mdapi project in vscode
  • Run the below command in the terminal
sfdx force:mdapi:convert -r mdapi -d <workspacelocation>\dxatscale101-source\dreamhouse-app
  • Run the sfdx force:mdapi:convert command
  • copy the .gitignore file and data folder from mdpai project root to source project root to dxatscale101-source repository
Observe the difference between mdapi and source format. Object Metadata is decomposed into multiple files, this helps when you have a large project with multiple objects having a large amount of fields. Tracking the changes in fields and record types is relatively easy and time saving.
All challenges from here on will use source format
  • Open the new source project in VSCode
  • Delete force-app folder
  • Replace force-app with dreamhouse-app in the sfdx-project.json file
"packageDirectories": [
"path": "dreamhouse-app",
"default": true
"namespace": "",
"sfdcLoginUrl": "",
"sourceApiVersion": "52.0"

Make the following changes in the org

  • Set Compliance Categorization as GDPR to all fields in Broker__c object
    • Open Playground
    • Setup --> Object Manager --> Search Broker in Object finder--> Fields & Relationships --> Email --> Edit --> set Compliance Categorization as GDPR
    • Follow this step in all the fields in the Broker object
  • Setup a path on property status
    • Setup --> Path Settings --> new path --> use below details on Name and Record Type page and click Next--> Fields and Text page no changes click next --> Activate the path and then click Finish
      Path Name
      Property Status
      API Reference Name
      Auto populated from path name
      Record Type
      Auto populated as Master
  • Add the property status path to Property record page
    • Open Dreamhouse app in App launcher
    • Open Properties Record tab and open any record
    • Click Setup gear Icon --> Edit page --> search path in component finder --> add the path component below the compact layout
    • Save the changes and click back

Retrieve the changes in the org using one of the below sfdx force:source:retrieve commands (Use the -h flag to understand usage)

sfdx force:source:retrieve -u <playground-1> -x <path to package.xml>
sfdx force:source:retrieve -u <playground-1> -m <metadatatype:medataname>
sfdx force:source:retrieve -u <playground-1> -p <sourcepath to retrieve>
Take the time to discuss and understand these commands

Make the following changes in the local source code

  • Update all the fields in Property__c to change the Compliance Categorization from PII to GDPR
  • Let's add a Broker image to Broker card component in property detail page. Replace brokerCard.js and brokerCard.html with below snippet and create a new file brokerCard.css with below snippets
    <lightning-card title="Broker Details">
    <template if:true={}>
    <div class="slds-var-m-around_medium">
    <lightning-layout-item size="3">
    <img src={brokerImage}></img>
    <lightning-layout-item size="9">
    <template if:true={property.error}>
    friendly-message="Error retrieving data"
    import { LightningElement, api, wire } from 'lwc';
    import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
    import { NavigationMixin } from 'lightning/navigation';
    import BROKER_FIELD from '@salesforce/schema/Property__c.Broker__c';
    import BROKERIMAGE_FIELD from '@salesforce/schema/Property__c.Broker__r.Picture__c';
    import NAME_FIELD from '@salesforce/schema/Broker__c.Name';
    import PHONE_FIELD from '@salesforce/schema/Broker__c.Phone__c';
    import MOBILE_PHONE_FIELD from '@salesforce/schema/Broker__c.Mobile_Phone__c';
    import EMAIL_FIELD from '@salesforce/schema/Broker__c.Email__c';
    const BROKER_FIELDS = [
    export default class BrokerCard extends NavigationMixin(LightningElement) {
    @api recordId;
    brokerFields = BROKER_FIELDS;
    @wire(getRecord, { recordId: '$recordId', fields: PROPERTY_FIELDS })
    get brokerId() {
    return getFieldValue(, BROKER_FIELD);
    get brokerImage() {
    return getFieldValue(, BROKERIMAGE_FIELD);
    handleNavigateToRecord() {
    type: 'standard__recordPage',
    attributes: {
    recordId: this.brokerId,
    objectApiName: 'Property__c',
    actionName: 'view'
    img {
    width: 100px;
    height: 100px;
    border-radius: 50%;

Deploy the changes to both the playground using sfdx force:source:deploy command (The reference to documentation is attached or use the -h flag to understand usage)

sfdx force:source:deploy -u <playground-1> -p dreamhouse-app -w 30
Once the metadata is successfully committed, commit your changes to the repo.

Create a new repo to publish your new source format project

  • Create a new repo in your GitHub Account with the below highlighted details
  • Get the newly created repo URL
  • Follow the below commands in the order from your Terminal to publish your local repo
    git init
    git add .
    git commit -m "First commit"
    git remote add origin <new repo url you copied>
    git remote -v
    git push origin master


Congrats! Now you have understood how to create a new sfdx source project and convert an existing project into source format, and also understood the similarity between Source and MDAPI. Please note that source format is only a local decomposition done by the CLI and the Salesforce Org doesn't understand source format.