Replace IDE with VS Code & SFDX for Metadata Deployment and Retrieval from Non-Scratch Orgs

In this blog, I would like to discuss the steps to follow for metadata deployment or retrieval using VisualStudio Code and SFDX. Salesforce discontinues the support of IDE from Spring 18 since they opted the powerful and open source VisualStudio Code as their official IDE.


Create a Project with Package.xml

Create a SFDX project by selecting Create a project with manifest option from the command palette (ctrl+shift+P | cmd+shift+P). Or Use the navigation View -> Command Palette in Mac OS.

  • Then it prompts for a project name
  • As you can see below, sfdx project structure will be created with package.xml file.

Connect to a Salesforce org

  • Project should be connected to a salesforce org, that is performing with an Authorize an Org command. In the background, a login request to the desired (prod/sandbox) org type based on our selection as shown upcoming screenshots.
  • Select org type to be connected
  • Then, you have to mention an alias name, that will be helpful for you to refer the org without using lengthy username for other commands(not from command palette ).
  • Once after the successful login, you could be able to see the alias org name in the bottom tab of VS code along with a connection icon.

Retrieve metadata using Package.xml

  • To retrieve the metadata from connected org, right click on the package.xml in the manifest folder and select the Retrieve Source in manifest from org option.
  • As you can see the, force:source:retrieve command invoke in the background by referring the package.xml as the manifest for that operation.
  • Retrieved metadata will be scripted in the output tab and available in the respective folders in the project structure
  • As you can see the below classes are retrieved to VS code using the retrieval option from the command palette.
  • To create an apex class, type SFDX: Create Apex Class, then it prompt for a class name to be created

Deploy a metadata

  • To deploy the created class from the VS code to org is very simple. Right click on the class to be deployed and select the deploy option.
  • You will be notified once after the action is performed and able to see the deployed class in the org if the action was a success.
  • To deploy multiple components to the org, you should create your selections in to a package.xml or a seperate xml file which possess the same xml schema. Right click on the file and select the deploy option. you will be notified once after the action is done.


Leave a Reply

%d bloggers like this: