Wednesday, October 10, 2018

VSCode with Salesforce - How to install.

Visual Studio Code is a popular editor available for Windows, Mac OS and Linux. Do not confuse it with Microsoft Visual Studio. Microsoft Visual Studio is used by programmers for programming mainly on and for Windows Platform. On the other hand, Visual Studio code is a light editor used for programming languages like Java, C, C++, C#, Javascript, etc. It has basic features which are generally found in normal editors/IDEs but in addition to that it has several cool and advance features like VS Code Live Share, Slack Chat etc. It has a very rich ecosystem. Most of the features are available as extensions. 

Salesforce development support in vscode is enabled through the Salesforce extensions for VSCode (https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode).
The extension pack or bundle enables the development of visualforce, lightning component, apex and debugging in vscode. In addition to that you get code completion for apex, visualforce &lightning code. The extensions are fully developed (with support from other developers) and supported by Salesforce. Some of the blogs are referring the installation of "ForceCode" extension which is a totally different extension and unrelated to what Salesforce has released.

Visual Studio Code has in in built support for version control tools like git, but you need to install git separately.

Now let us see how to install and use Visual Studio Code.

Start by first installing latest version of Salesforce CLI. You can check the blog post https://www.salesforce-vscode.com/2018/10/salesforce-cli-installation.html for instructions.

Now download and install latest version of Visual studio code from https://code.visualstudio.com .For Windows you will see two different types of installers User Installer and System Installer. Installing the user setup does not require Administrator privileges which is very helpful in corporate environments as most of the users do not have administrator privileges. User setup also provides a smoother background update experience.



Installation is straight forward. Click on the downloaded exe and select default options in the wizard to complete the installation.

Open Visual Studio Code and click on extensions tab. Install "Salesforce Extensions for Visual Studio Code". This will install Salesforce CLI Integration for Visual Studio Code, Apex Code Editor for Visual Studio Code,Apex Debugger for Visual Studio Code,Apex Replay Debugger for Visual Studio Code,Lightning Component Code Editor for Visual Studio Code & Visualforce Code Editor for Visual Studio Code. If these are not installed automatically due to some reason , search and install these separately. 




Alternatively you can download the extensions from the VS Code extension marketplace https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode.

Code Auto Completion based on Language services requires Java 8 to be installed on the machine. Install it from here - https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Higher versions of Java is not supported at this moment, so make sure you install the correct version, otherwise you may face issues.
Once Java is installed set the JAVA_HOME or JDK_HOME environment variable on your computer.
Alternatively you can set the path in Visual Studio Code itself. Goto File ->  Preferences -> Settings on Windows  and search for apex in the search box. Click on edit in settings.json for "Salesforcedx-vscode-apex › Java: Home". Set the java path based on you java installation.


Do a quick check of the installation by checking the command pallete. Check if SFDX commands are available in it.


We are now ready to use Visual Studio Code for development. It can be used for development against the scratch orgs or against the developer orgs, sandbox etc.
x

No comments:

Salesforce Flow Tutorial #3 - What is Record Triggered Flow - Post To Chatter

 In this tutorial we will learn how to create and use Record Triggered Flow. The Record triggered flow can be used to fulfill requirements w...