Visual Studio Code Salesforce



Visual Studio Code is the latest IDE for Salesforce Development and in this blog post, I am going to tell you how you can setup Visual Studio Code for Salesforce Development. So, let's begin. Download and Install VSCode. I'm a long time visual studio developer and am stating with VS Code. I found the Format Code shortcut (Shift + Alt + F) but I want it to run automatically whenever I press. Is there a configurat.

Introduction

Vscode

In the “Salesforce DX – SFDX – Guide” article, we explained what it is and how to use SFDX. Generally, the Salesforce DX project has a specific project structure and source format. Source format uses a different set of files and file extensions from what you’re accustomed to when using Metadata API. But what if you want to use Visual Studio Code with the Salesforce CLI Integration plugin but your repository is in the Metadata format?

Code

How to configure the project?

NOTE: This doesn’t work if you want to retrieve or deploy SObject definition (SObject configuration, fields, etc.) – you will need to use the ANT Migration tool for that (here is our guide).

Create a Salesforce DX project

  1. use Ctrl+Alt+P keyboard shortcut
  2. enter SFDX: Create Project
  3. choose Empty
  4. enter your project name
  5. choose project location

An empty project has been created in the source format.

Authorize your credentials

If you do not have the org authorized yet:

  1. use Ctrl+Alt+P keyboard shortcut
  2. enter SFDX: Authorize an Org
  3. choose the org type that you want to authorize
  4. enter an org alias
  5. log in to a destination org using the Salesforce login page

If you’ve already created the alias for your org:

  • click on the “No Default Org Set” icon in the sidebar and choose the existing alias

You have been authorized.

Delete the force-app folder

Go to the project directory and clone the repository

The remote repository has been cloned.

Also, the Source Control has been initialized.

Update the sfdx-project.json file to the new project directory

Visual Studio Code Salesforce Dx

  1. open the sfdx-project.json file
  2. change the “path” to the name of the project folder from repository

Verify if you can use the Salesforce CLI functions

Make a change to the file:

Compare the local file to the version in the org:

Deploy changes:

Was it helpful? Check out our other great posts here.

Resources

Visual Studio Code Salesforce Extension Pack

Article Rating