Visual Studio Code Salesforce



Introduction

  1. Vs Code Trailhead
  2. Sfdx Vscode
  3. Visual Studio Code Salesforce Extensions

Vs Code Trailhead

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?

Salesforce help; salesforce training; salesforce support. Visual Studio Code is the go-to code editor for Salesforce developers. It's free, open-source, and available for Windows, Linux, and macOS. This editor has easy-to-install extensions for syntax highlighting, code completion, and more. In this project, we install Visual Studio 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

Sfdx Vscode

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:

Salesforce
  • 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

  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

Article Rating

Install Salesforce Extensions for Visual Studio Code

Visual Studio Code is the go-to code editor for Salesforce developers. It's free, open-source, and available for Windows, Linux, and macOS. This editor has easy-to-install extensions for syntax highlighting, code completion, and more.

In this project, we install Visual Studio Code and the recommended Salesforce Extension Pack.

  1. Download and install the latest version of Visual Studio Code for your operating system. If you already have Visual Studio Code installed, there’s no need to reinstall it.
  2. Launch Visual Studio Code.
  3. On the left toolbar, click the Extensions icon .
  4. Search for Salesforce Extension Pack and click Install.

Note

Some features, particularly Apex support, in Salesforce Extensions for Visual Studio Code depend on the Java Platform, Standard Edition Development Kit (JDK). Only JDK 8 and 11 are supported. If you have another version of Java installed, you need to also install JDK 8 or JDK 11. Once you install the right JDK, use the following links to configure your setup:

Ensure Your Development Environment Is Ready

Now that you’ve installed Visual Studio Code and enabled the necessary extensions, you need to test them out.

  1. In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
  2. Enter sfdx to filter for commands provided by the Salesforce Extensions.

Visual Studio Code Salesforce Extensions

As you use more SFDX commands, those commands will show up in the recently used panel.

In the final step, you create your first Lightning web component and add it to your org’s home page.

We won’t check any of your setup. Click Verify Step to go to the next step in the project.