Visual Studio Code (VSCode) is a free, cross-platform code editor with a strong plug-in community which extends its capabilities. Salesforce has created plug-ins to work with VSCode and has become the preferred editor for editing code with SFDX.
Visual Studio Code can be used by both developers and QA staff alike.
GIT
The GIT Guide from GitHub is a great resource for setting up and configuring GIT
Mac Users - You may want to consider connecting with SSH and adding SSH key to the SSH Agent
Getting a workstation setup with VSCode and configured for Salesforce development is a straightforward approach, the steps below outline what is needed to perform regardless if the developer or quality assurance engineer is running on a PC or a Mac.
Download and Install Visual Studio Code
Java 11 Platform, Standard Edition Development Kit Some features in Salesforce Extensions for VS Code depend upon Java (Standard Edition Development Kit (JDK))
The AdoptOpenJDK is a recommended alternative to Oracle's Java which carries licensing fees.
Install the Salesforce CLI
Install the official Salesforce Extension Pack into Visual Studio Code.
Configure Settings in Visual Studio Code to point to the JVM
Open Settings, Navigate to User
Select Salesforce Apex Configuration
Select Java: Home and set path correctly (See example below)
Connect VS Code to Azure DevOps GIT Repos
Learn DX
You may want to follow this trail to get familiar with Salesforce DX
Salesforce needs to be configured to enable SFDX. This is a one-time setup for the Developer org.
Setup Dev Hub and G2P in your Salesforce edition
Navigate to Setup > Settings > Development > Dev Hub
Move the slider to enable Dev Hub and G2P Packaging
From a command prompt in Visual Studio Code issue sfdx force:auth:web:login
to log into the Dev Hub using the CLI, which will authorize you to create scratch orgs.
SonarLint - Provides realtime feedback on writing better code.
Connects with SonarCloud (free for public projects ~$10/mo for most Salesforce projects)
Prettier - Keeps code formatting consistent
C# - For building Automated UI Tests with Selenium
XML - Helps with working with XML Files
Automatically push code to org when saving:
salesforcedx-vscode-core.push-or-deploy-on-save.enabled
to true
.
Trailhead Module:
-- Valerie Belova
Along with creating a repository for each package, an sfdx project should also be created for each package. The sfdx project along with the repository will live in the same directory. It's important to name the project after the particular package or feature that the team will be working on.
In VSCode, navigate to the top row, and select 'Terminal'. A new terminal window should appear at the bottom portion of the screen.
Type in the command sfdx force:project:create --projectname "Name" --manifest
This will populate the directory with sfdx files
Authorize your provided org, using sfdx:force:auth:web:login --setdefaultdevhubusername --setalias "Alias"
--setalias
make is easier to access your org when running commands that push source to your org
--setdefaultusername
makes it so that org is the default org. If you don't specify an org when working with files or packages, they will automatically be pushed to the default org.
This json file will contain the instructions for scratch org creation. Normally, when you've authenticated an org, and you're ready to start developing you'll spin up a scratch org, push data into the org, and start developing. You can include thigs like edition, name, and features
Edition—The Salesforce edition of the scratch org, such as Developer, Enterprise, Group, or Professional
Add-on features—Functionality that is not included by default in an edition, such as multi-currency.
Settings—Org and feature settings used to configure Salesforce products, such as Chatter and Communities.
Note: For more information about the scratch org definition file: Visit Here
The First Scratch Org
SFDX development is performed in a Scratch Org which is an empty local Salesforce environment.
Create a Scratch Org from project-scratch-def.json
sfdx force:org:create --definitionfile "config/project-scratch-def.json" --setalias "Alias"
sfdx force:source:push
to push the project source into the scratch org
sfdx force:package:install --package
to install all of the packages into the org. Make sure to install in dependency order.
sfdx force:user:permset: assign ---permsetname "Permission"
allows the scratch org to access data that is limited to the hub.
sfdx force:org:open
to open up the project in your browser.
Unlike a sandbox, the Scratch Org will have no data in it when it is created. To ensure data is available in a Scratch Org to support the development and testing efforts data will have to be scripted in, fortunately, Salesforce provides capabilities to support this.
This is the basis for starting up a project. Scratch org management will be explored later in the wiki.
This is the json file that describes all of the packages within your project. It's a useful place to refer to the packages in your org. Although, when you first create the project, this json file will only contain the force-app path. It's important to jot down the '0ho' IDs of packages in this file.
To find package names and IDs, run sfdx:force:package:list
Note: for more information about parameters you can specify in your sfdx-project.json file, click Here.