SFDX setup guide – For non-scratch org

SFDX setup guide – For non-scratch org

SFDX is a great way to develop Salesforce programmatic solutions. It allows:

  • Continuous Integration update source as you continue with your development
  • Team Development and Collaboration- multiple developers can work on different Scratch Orgs and merge code in DevHub

In this post, you will learn how you can setup SFDX for your Salesforce Org.

1. Download VS Code

The first thing you need to do is to download VS Code for your operating system from here.

2. Install Necessary Extension

Extensions are the life of VSCode, without extensions, it is another dead IDE. Make your VSCode alive by installing below extensions:

3. Install Salesforce Command Line Interface

Salesforce has released it’s command line interface to work with Salesforce Orgs from your local machine. Install salesforce CLI from here.

Note: After installation, please make sure you are updating your CLI plugin. Run below command in the terminal or command prompt:

sfdx update

4. Create a project and follow below steps

You would have to deal with a lot of commands here. However, some of the commands can be avoided by using the command palette in VSCode. To open the command palette, press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows or Linux).


  • Create a new project – Open command palette and type “SFDX: Create Project”. Provide the project name and location. This will create a blank SFDX project in your local machine with all necessary files. Alternatively, you can run below command as well:
    sfdx force:project:create -n <project name> -d <output directory>
  • Authorize your org – After creating your project, it’s time to connect with your Salesforce Org. In command palette, type “SFDX: Authorize an org” and select your instance. It can be production (choose production for developer org as well), Sandbox or you can give a custom URL as well for my domain enabled Orgs. After selecting your instance, give your org a name, and it will open Salesforce login page in your browser. After successful login, you may close the browser. Alternatively, you can run below command:

    sfdx force:auth:web:login –setalias <your org name> –instanceurl https://login.salesforce.com
  • Retrieve metadata from your org – Your org is authorized and connected with VSCode. Now you can retrieve metadata from your org. Create your package.xml file to retrieve metadata components. Save the file in your system. It’s better to save it inside the project folder as we need to provide its path to retrieve metadata. Run below command to get retrieve metadata components:

    sfdx force:mdapi:retrieve -r <output directory path> -k <path to package.xml file>

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

  • Unzip retrieved metadata – Above mdapi retrieve command will download the metadata in zip format. We need to ensure that we unzip first. Run below command unzip:

    unzip <zip file path> -d <output folder path>

    Example: unzip ./metadata/unpackaged.zip -d ./metadata/unzip_metadata

  • Convert metadata to source format – Converts metadata retrieved via Metadata API into the source format used in Salesforce DX projects. After converting your metadata, you would be able to get some of the awesome VSCode features like code completion. Run below command to convert metadata:

    sfdx force:mdapi:convert -r <unzipped metadata folder path>

    Example: sfdx force:mdapi:convert -r ./metadata/unzip_metadata

So now you have your metadata in soure format VSCode. You can modify the metadata, create new metadata like a new Apex Class or a new Lighting Component. Once you are finished with your changes, you can deploy your metadata back to your Salesforce org. Follow below steps:

  • Deploy your components back to Salesforce org – Now you are done with your local changes and it’s time to deploy these changes back to Salesforce org. Run below command to deploy your components:

    sfdx force:source:deploy -p <source file/folder path>

    Example: sfdx force:source:deploy -p ./force-app/main/default/aura/CarSearchForm/CarSearchForm.cmp

Also Read: Create Lightning Web Component – SFDX

Also Read: SOQL performance improvement and Skinny Tables in Salesforce

Also Watch: SFDX Setup For Scratch Orgs

I hope you find this guide useful to setup SFDX for yourself. If you have any queries, feel free to put a comment here, I would try my best to answer.

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Salesforce.com Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

Leave a Reply

Close Menu