Setting up Development environment for Salesforce

Sachin Upmanyu
4 min readJul 13, 2020

Traditionally Salesforce Development has been done over Eclipse or Developer Console, and version control has been tricky to setup.

SFDX was made generally available in Oct 2017, and since then it has come a long way. With SFDX, we now have the choice and flexibility to choose our Development tools.

Briefly, what is SFDX

  • It is a set of Tools to facilitate modern development practice.
  • SFDX CLI: Enables you to move away from Traditional IDEs(Eclipse, Developer Console) and use other popular IDEs (Visual Studio Code, Illuminated Cloud).
  • Scratch Orgs: Instead of creating Sandboxes for development, create short-term Salesforce environment to develop new features, run CI / CD pipelines.

If you are looking to setup your Salesforce development environment around SFDX, and introducing some automation to make your life easier, this post might be helpful for you.

We will be looking to setup

  • SFDX CLI → To manage scratch orgs, push/retrieve code changes from org.
  • Visual Studio Code → This is where we’ll write our code, ditch Developer Console.
  • Rollbar Integration for Apex →Monitor handled/unhandled exceptions, helps in debugging.
  • Slack Integrations for GitLab, Rollbar →Slack will be our hub for notifications.

Setting up the CLI

First, Go through Official Documentation and Prerequisites for understanding and installing SFDX CLI.

  1. Mainly there are 2 ways you can utilise SFDX CLI for development, with sandboxes or with Scratch Orgs.
  2. If you want to create 2nd generation packages, or setup automated testing with CI pipeline, you’ll be needing Scratch Orgs and will need to enable Dev Hub for this (check “Before you begin” link).
  3. If you are unable to provide licenses, you’ll need to give up on Scratch Orgs and instead use Sandboxes for development.

Setting up Visual Studio Code:

But first, Prerequisites.

  1. Install Git

git-gui is a minimalistic GUI tool, remove if not needed.

2. Install Java 8 : needed for running the Apex Language Server

Windows:

  • Download Link
  • Set Java Home: setx -m JAVA_HOME “C:\Progra~1\Java\jdk1.8.0_XX”

Imp: Cross check the path if it actually exists and points to correct directory before setting path

  • Check if Java Home has been set correctly echo %JAVA_HOME%

Linux(Ubuntu):

If JAVA_HOME is not set, follow next steps

  • Open the bashrc file for editing: nano ~/.bashrc
  • Add this line in end: export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_241

Imp: Cross check the path if it actually exists and points to correct directory before adding to .bashrc

  • Reload the file for changes to take effect: source ~/.bashrc
  • If you run into any other installation issues, refer to this guide.

3. Download & Install Visual Studio Code

4. Setup Extensions

Settings Sync has advantage of creating a master configuration tailored for your particular project which can be shared and enforced on other dev machines. For example, you can control which extensions are installed in dev machines, their configurations, user settings & keyboard shortcuts.

Run these commands to check if all tools have been installed successfully.

  1. $ sfdx
  2. $ git --help
  3. $ echo $JAVA_HOME // for Linux
  4. $ echo %JAVA_HOME% // for Windows
Check if executables are properly setup

Rollbar Integration for Apex

  • Get real-time error notifications with stack traces for Apex.
  • You’ll need to create an account for Rollbar and can start with a free plan with 5000 events per month limit.
  • Check Integration guide with Salesforce on how to setup.
  • After this you’ll be able to write custom log messages to Rollbar.
try {...} catch (Exception exc) {    rollbar.Rollbar.log(exc);}
  • Pro tip : put unique strings with your logs for easy searching.

for example: rollbar.Rollbar.log('Logger_XcEr6T7y: Logging Custom Message');

Slack Integrations

Slack is a great collaboration tool, it provides integrations with many third party tools, and creates an eco-system where all your alerts/notifications can accumulate at a single place.

For starters, we are integrating GitLab & Rollbar.

Integrate GitLab:

  • To get updates for any git activity (get instant notifications for push, CI/CD pipeline updates, Issue, MR updates).
  • Create a separate channel for your project’s GitLab updates.
  • Check Official Implementation Guide.

Integrate Rollbar:

  • Get instant crash, handled/unhandled exception notification in Slack.
  • Again, it’s better to create a separate channel in Slack for these alerts.
  • Check Official Implementation Guide.

Additionally, you can look to integrate SonarQube with your CI/CD pipeline for static code analysis.

While this post doesn’t cover all the topics in depth, I hope this will give an idea and help setup your Salesforce development environment.

--

--

Sachin Upmanyu

Salesforce certified developer (SFDC & SFCC), DevOps enthusiast.