Salesforce DX and my experience using it within a consultancy-based project
Publish Date: January 10th 2019
Salesforce DX (short for development experience) was first mentioned in the 2016 Dreamforce event where it was described as a new development experience that aims to essentially replace existing Salesforce development tools (e.g. Mavensmate, Ant etc…) to help developers to ‘build together and deliver continuously.’. Which some of these existing tools did not seemingly do very well. More information on Salesforce DX can be found here. As a Salesforce Consultant I have been able to use this tool within two projects, based on this experience I will be:
Explaining the USPs I found using Salesforce DX
Explaining how I setup Salesforce DX to work in a development environment
USPs I found using Salesforce DX:
Source Driven Development - One of the biggest changes I had to adapt to was the change to source driven development. What a lot of people may not know, it was defiantly a shock to me when I first started dabbling in the salesforce ecosystem, was that salesforce development is not reliant on source control tools (a means of keeping track of your code). Rather the source of truth would just be the development org itself. This all changes with the introduction of Salesforce DX however, where you can integrate with multiple source control providers.
Easily Created and Disposed Salesforce Environments - The second biggest change I noticed was the shift away from single large shared development orgs potentially shared between multiple developers and even project teams. With the introduction of ‘Scratch Orgs’ – a temp clean slate Salesforce org (lasts for max 30 days, the days can be manually set) is specifically for development of a new project or a new feature. It also works as a great test environment per sprint (2 weeks in most of my projects). These scratch orgs can be used to develop each individual user story, and after the development is complete? Push the source code to the VCS and delete the scratch org and move to the next US!
CLI - Much of the focus with Salesforce DX is speed, speed, speed, given most projects is adopted with an agile methodology this is key. Salesforce DX achieve this through the adoption and encouragement of CLI. Salesforce DX CLI allows easily and quickly creates organizations with full or partial copy of code and generation of test data.
Explaining how I setup Salesforce DX to work in a development environment:
This section will explain how I setup SFDX for use within my projects:
Step 1 - Enable the Dev Hub Setting in your Org
This setting is what enables you to create scratch orgs, manage scratch orgs and alter setup configuration for these environments. This setting can be enabled for paid and FREE production environments.
1. Click on setup
2. Search ‘Dev Hub’ and click on it
3. Toggle the Switch to on (Green)
Step 2 - Download and install VS Code and the Salesforce Extension in VS Code
1. Download and install the Salesforce CLI
2. Download and install the latest version on VS Code
3. Launch Visual Studios
4. On the left toolbar, click on the Extensions icon/li>
5. Search for ‘Salesforce Extension Pack’
6. Install the pack
7. Click the ‘Reload’ button to re-launch VS Code
Step 3 - Authorise your DevHub org and set it up as default with an alias
1. You will now be authorising your dev hub org (this is the org setup in step 1) and setting it as our default org
2. In VS Code press SHIFT, CMD and ‘P’ – for mac users – and type Authorize and select the ‘SFDX: Authorize a Dev Hub’
3. A new Salesforce login window will then open, enter the login details of the initial DevHub created in step one and login
4. After login has succeeded then in VS Code press SHIFT, CMD and ‘P’ – for mac users – and type Create a Default scratch org and select ‘SFDX: Create a Default Scratch Org…’
5. Select the project location
6. Give the scratch org a name alias
7. Enter the number of days you want the org to stay active (can be between 1 and 30 days, with 7 days being default)
8. A default scratch org will then be created automatically where you can deploy existing meta data or make use of this org as a development environment.
Get in touch!
Want to get in contact? That's great! Give me a call, send me an email or connect through the below social media platforms and I will get back to you as soon as possible!