Its been around 3 years that Salesforce has released new tooling set for developers – Salesforce DX. I’ve been working on Salesforce since days of S-Control around 2008 and have seen extreme changes on platform for better.
To be honest, it’s tough to keep yourself up to date on latest changes that Salesforce has been doing , however there are resources like Medium, Trailhead and many other blogs to help you get up to speed.
I’ve seen days and written code on Force.com IDE, Developer Console, many web based IDE and definitely my heart and love at the moment is with VSCode more importantly Scratch Org & unlocked packages.
Purpose of this blog post is to bust some of myths around using Scratch Org in Salesforce DX however before I start, lets agree on below aspects of project development & management
Most of projects in Salesforce follows Agile and one of most important aspect of Agile is Devops. Your team should spend enough time & energy in planning Devops strategy like branch structure, tools, processes etc. In my experience , Devops is more about process rather than tool.
On basis of above point, Source of truth for code & configuration should be your Source Code Management , which in most of cases is Git.
What if your project is not following above 2 principles ? Well, you might already able to relate some of problems like why code is overwritten , no track of which class or fields created by who and why ? Your team spending most of time fixing deployment issue instead of working on actual implementation.
Lets not spend more time and directly jump on some of myths about using scratch org
Myth 1 – Scratch Org is only for packaging & ISV partners
Scratch Org can be used for quick POC or actual implementations. I’ve been using scratch org for each user story which normally takes 1-3 weeks of implementation. Every time, scratch org created, I get liberty to choose which Git branch would be source of truth. Can you refresh dev pro sandbox from Full copy or use 10 days old code that was in production ? There are many other considerations while creating sandbox, you don’t have much control on which metadata would be carried over as starting point.
Error 1 : Language not supported in translation workbench. fr_CA Not available for deploy for this organization.
Solution : This error could be thrown from Salesforce DX while create unlocked package version. To solve this, we need to provide of scratch org configuration file informing that package needs translation. It seems little off that why would unlocked package need path to scratch org , however this is how it is. Example file project-scratch-def.json
Before deploying metadata in Sandbox of production, have you felt that how great it would be to generate configuration workbook ? Or compare sandboxes for difference ? Or check if fields are used on any page layouts or not ? Dear reader, you are in need of custom Salesforce DXplugin.
You heard it right, Salesforce DX allows custom plugin development. So now question is, how do you connect to Salesforce Org ? Do you need to know about OAuth or Single Sign On (SSO) ?
We have gone through few blog posts about SFDX and its capabilities in past. In this post, I will explain steps on how to use SFDX with developer, Sandbox or Production Org. In short we will discuss how to use SFDX with non Scratch Orgs. We would be using official Salesforce IDE for SFDX, which is VSCode.
Assumption – VSCode extension is already installed in your VSCode.
Create SFDX project in VSCode
Open VScode and press cmd+Shift+p, It will give some option. Select SFDX: Create Project.
Note : Everything we are discussing here is completely covered as part of Live coding in Apex Salesforce Saturday organized by Amit. Would like to thank Mohith for his support and answers during the demo. It also shows How SalesforceDX can be used daily by developers to perform development.
If you have existing VCS which stores metadata information about your Salesforce instance in old format, dependent on package.xml and you want to use Salesforce DXthen this blog post is for you. As you might already know, Salesforce DX does not need package.xml and can automatically detect changes in your Salesforce instance, therefore new Salesforce DX project format is different. In this blog post we will see, how Salesforce DX can be used without enabling Developer Hub and using Salesforce DX with normal Salesforce instances.
There are two solution to this problem
Keep using old Project format and use Metadata API to retrieve and deploy
Convert old project format to Salesforce DX project Format
If we already have Salesforce Metadata API, Force.com IDE and other tools then why do we need one more tool like Salesforce DX ?
In tools like Changeset, Metadata API or Force.com IDE, source of truth is Sandbox. Although we can setup process and continuous integration (CI) to use some source code management (SCM) like Git or SVN. However these kind of setup takes time, expertise and lot of effort.
Salesforce DX not only solves above problem but
Ability to consider SCM as source of truth
Use any favorite IDE or any SCM
Powerful CLI to help minimizing complexity of setting up CI
Updated Force.com IDE to support Salesforce DX if you are not comfortable with CLI
and most important, spin off Scratch Orgs within minutes through script to quickly work on POC or package based development
What are scratch Orgs ?
Salesforce DX can be enabled for any Salesforce instance and they are known as Developer Hub. One Developer Hub can have multiple Scratch Orgs. Scratch Orgs are temporary Salesforce org which can be created quickly and metadata can be deployed from SCM. These kind of Orgs can be used by developers to perform quick proof of concept or build and test packages. Once package is build and saved back on SCM, scratch org can be destroyed easily.