This extension pack includes tools for developing on the Salesforce platform in the lightweight, extensible VS Code editor. These tools provide features for working with development orgs (scratch orgs, sandboxes, and DE orgs), Apex, Aura components, and Visualforce.
Salesforce Extensions for Visual Studio Code The Salesforce Extension pack includes tools for developing on the Salesforce platform in the lightweight, extensible VS Code editor. These tools provide features for working with development orgs (scratch orgs, sandboxes, and DE orgs), Apex, Aura components, and Visualforce. Installing Microsoft Visual Studio You’ll need to install Microsoft Visual Studio to use Salesforce APIs. Visual Studio is a development environment that enables you to create robust.NET applications. To install Microsoft Visual Studio, you’ll need a Windows system with Internet access.
- Step 3: – Download “Salesforce Extensions pack” After you have installed the Visual Studio Code in your machine. Go to below link and install the extension. If it asks to open with VS code then click “Open with Visual Studio Code”.
- Salesforce XML Formatter Description. The main purpose of this extension is to provide a standard way to format and sort tags for metadata files (with extension '.xml' ) on Salesforce orgs. The tags inside the XMLs are sorted in a fixed order following Salesforce-specific set of rules.
- Come learn how the Salesforce Extensions for Visual Studio Code will make you a more productive and (hopefully) happier developer. You will see all the latest features such as the no-cost Replay Debugger and improved testing capabilities. This session will be fast paced and loaded with demo, tips, and tricks that you can apply to your work immediately. Or at least after Dreamforce is over.
Prerequisites
Before you set up Salesforce Extensions for VS Code, make sure that you have these essentials.
Salesforce CLI
Before you use Salesforce Extensions for VS Code, set up Salesforce CLI.A Salesforce DX projectOpen your Salesforce DX project in a directory that contains an
sfdx-project.json
file. Otherwise, some features don’t work.
If you don't already have a Salesforce DX project, create one with the SFDX: Create Project command (for development against scratch orgs) or the SFDX: Create Project with Manifest command (for development against sandboxes or DE orgs). Or, see create a Salesforce DX project for information about setting up a project using Salesforce CLI.Java Platform, Standard Edition Development Kit
Some features in Salesforce Extensions for VS Code depend upon the Java Platform, Standard Edition Development Kit (JDK). You need to have either version 8 or version 11 of the JDK installed.If you don’t already have version 8 or 11 of the JDK installed, you can install the latest version of the Java 8 JDK from Java SE Development Kit 8 Downloads or the latest version of the Java 11 JDK from Java SE Development Kit 11 Downloads.
If you also use other versions of the JDK, set your VS Code user setting
salesforcedx-vscode-apex.java.home
to point to the location where you installed Java 8 or 11.Visual Studio Code v1.26 or later
Documentation
For documentation, visit the Salesforce Extensions for Visual Studio Code documentation site.
Open Source
Bugs and Feedback
To report issues with Salesforce Extensions for VS Code, open a bug on GitHub. If you would like to suggest a feature, create a feature request on GitHub.
Included Extensions
The Salesforce Extension Pack extension installs these extensions.
- Salesforce CLI Integration
This extension (salesforcedx-vscode-core
) interacts with Salesforce CLI to provide core functionality. - Apex
This extension (salesforcedx-vscode-apex
) uses the Apex Language Server to provide features such as syntax highlighting and code completion. - Apex Interactive Debugger
This extension (salesforcedx-vscode-apex-debugger
) enables VS Code to use the real-time Apex Debugger with your scratch orgs or to use ISV Customer Debugger for your subscribers’ orgs. - Apex Replay Debugger
This extension (salesforcedx-vscode-apex-replay-debugger
) enables VS Code to replay Apex execution from Apex debug logs. - Lightning Web Components
This extension supports Lightning web component bundles. It uses the HTML language server from VS Code. - Aura Components
This extension (salesforcedx-vscode-lightning
) supports Aura component bundles. It uses the HTML language server from VS Code. - Visualforce
This extension (salesforcedx-vscode-visualforce
) supports Visualforce pages and components. It uses the Visualforce Language Server and the HTML language server from VS Code. - Salesforce Lightning Design System (SLDS) Validator
This extension (salesforcedx-vscode-slds
) simplifies working with the Salesforce Lightning Design System (SLDS). It provides code completion, syntax highlighting and validation with recommended tokens and utility classes.
Currently, Visual Studio Code extensions are not signed or verified on the Microsoft Visual Studio Code Marketplace. Salesforce provides the Secure Hash Algorithm (SHA) of each extension that we publish. Consult Manually Verify the salesforcedx-vscode Extensions’ Authenticity to learn how to verify the extensions.
To start with the Salesforce Source Code repository Management with version controls like Visual Studio Code and GitHub, we need to have certain software installed in our systems.
1.Install Visual Studio Code and Salesforce CLI
Visual Studio Code : can be installed in any Macos, Windows and Linux operating system. To install go through the following linkhttps://code.visualstudio.com/ and download it according to your system requirements and install it in your system.
Salesforce CLIm : is a command line interface and helps you to run commands for Salesforce org and work with the metadata and files locally in your system which are retrived from Salesforce org. To install Salesforce CLI go through the following link https://developer.salesforce.com/tools/sfdxcliand select the prefered OS, download it and install.
Install Salesforce Extensions for Visual Studio Code
Extensions contain everything that needed for developing Salesforce applications using Visual Studio Code. Go throughhttps://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode and follow the instructions to install Extensions. Once the extensions are installed, Reload Visual Studio Code to finish installation.
Get Started With Visual Studio Code and Salesforce
To get started with project, click on Command Palatte(ctrl+shift+p) which you can find it in view option and ther are two ways to create a project and develop it.
If you are developing against developer edition, sandboxes etc orgs, you can use the command SFDX: Create Project With Manifest or if you are developing against scratch orgs, you can use SFDX: Create Project Command.
Visual Studio Salesforce Plugin
Upon clicking any of the command to create project, it will ask destination folder in your system to save the project locally and you can start woking on your project.
To work with the source or to deploy and retrive source from any org, first you have to authorize it. In Command palatte, click on SFDX: Authorize an org and you will get options like project default - use login URL defined in sfdx-project.json (https://login.salesforce.com/) to work in production org or for sandbox click on https://test.salesforce.com/ or you can enter custom url based on your requirement. You can change the login url in sfdx-project.json file and set sfdcloginurl to required one. In sfdx-project.json file, you can also change destination path.
Once you click on any of the above options, it will ask you to enter Salesforce login username. Upon entering username it will redirect you to the login page and when you login successfully then come back to the visual studio code, it will show you success message like Salesforce Authorized username with org id 1234567890.
Now you can create apex classes, triggers, visualforce pages, components etc in the project. To retrive source from authorized org, Right click on the files in project folder so that you can find a command SFDX: Retrive Source From Org. clcik on it to get source from the authorized org. You will get the components which are mentioned in your package.xml file which you can find in manifest file.
To deploy the modified source code or new one, click on SFDX: Deploy Source to Org command which you will find in the similar way as above. To deploy source to differnet org, logout from the current authorized org and login to the new one to continue.
Note:
1. You can deploy or retrive individual files to or from source org.
2. You can't deploy your code to production directly from visual studio code. It can fail sometimes so deploy using packaging or by converting your source code into metadata format.
Visual Studio Code and GitHub:
To start with Source Code Management with Visual Studio Code and GitHub, you must have a basic idea about Git and GitHub.
To get your Source code to GitHub, first you have to stage and commit your code changes in local system. This can be done by hitting on Git: commit and Git: stage cmmands or you can directly see in the source option which will be on the left side bar, when you open it you can see all the changes that you have done to your source code and click on check mark where you will get an option to Stage and Commit all the changes. Upon hitting it, commit changes are saved in your local directory.
Now, the changes have to be pushed to GitHub. To do this, makesure you have a repository created in GitHub.
To Push the changes to GitHub repository, Use command GIT: Clone and add URL( you can find it in your GitHub --> Repository--> Clone or download option and copy it) and hit on enter to connect with that repository. You can check that connection in Visual Studio Code at bottom left corner. Initialize the repository by GIT: Initialize Repository Command and you can work on that repository or you can add it the current workspace you are working on.
Now, you can Push the commited changes in your local to the github by GIT: Pushto the repository which you are currently working on or GIT: Push to command where you can see the option push to origin with the url which you have given for your repository. Upon clicking that option, your source code is published to Github and you can see the changes in Github. To push source code to different branches(you must have a branch created in Github), you can change the branches by clicking on the current repository which you can see in the bottom left corner, upon click select your desired branch or you can create a new one and push your code to that branch.
To Pull source code from GitHub to Visual Studio Code, follow the same process until initialization and click on GIT: Pull command or GIT: Pull the source code from GitHub to your local project from selected repository. To pull code from different branches, hit on GIT: Pull From command where you can get options.
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.