Salesforce CLI for non-scratch orgs

_config.yml

This blog post takes a deep dive on how to use DX for all developer, Prod and Non-prod Salesforce environments other than scratch orgs.

Pre-requisites:

  1. Install VS Code
  2. Install Salesforce Extensions for VS Code

You can refer this post for a crisp introduction on Salesforce DX.

Now if everything is set-up, let’s get started. Create a project as shown below: Open VScode and press cmd+Shift+p, It will give some option. Select SFDX: Create Project.

Now open the command line in the vs code and create a project using the below command

sfdx force:project:create --projectname Sfdcbrewery

_config.yml

Lets set an alias for the org using the following command:

sfdx force:auth:web:login --setdefaultdevhubusername --setalias sfdcbrewery

_config.yml

Now lets create a Metadata file to pull the components we want to work with as shown below:

_config.yml

 sfdx force:mdapi:retrieve -r metadata -u sfdcbrewery -k metadata/package.xml

  • -u : Username or alias of the Salesforce Org
  • -r : Location where zip file should be saved
  • -k : List of components to be retrieved using package.xml

As we get a Zip file, lets unzip it using the below command:

unzip -o metadata/unpackaged.zip -d metadata

_config.yml

In similar way, you can deploy your metadata using the below command:

sfdx force:mdapi:deploy -c -d ../mdAPIZip/unpackaged -u sfdcbrewery -w 10

  • -u : Which Salesforce Org to be used by Salesforce DX
  • -f : Zip file location containing metadata and package.xml
  • -c : Check only flag, Package would be validates only
  • -w : Wait time in minute for operation to be completed
  • -d : Folder location of non-zipped files, with package.xml in root

Resources:

  1. Jitendrazaa
  2. Dev blog

Keywords: #SFDCBrewery #SriharideepKolagani #SalesforceDX #SalesforceDevelopment #Salesforce #SFDCBrewery #Brewery #SalesforceOnlineTraining #SalesforceTutorials #SalesforceCertification

Written on July 7, 2018