SlideShare a Scribd company logo
SFDX
Salesforce Developer eXperience
2018
Introduction
Bohdan Dovhan
Senior Salesforce Developer
Salesforce Development Team Lead
Salesforce Certified Platform Developer I
Salesforce Certified Platform Developer II
Salesforce Certified Platform App Builder
8 years of Development experience
5 years of Development on Salesforce platform
What is SFDX?
SFDX is both a new set of tools and new features affecting development lifecycle.
SFDX helps to shift source of truth from production org to VCS repository.
SFDX is an opportunity to shift the source of truth management and org
development lifecycle [1]
SFDX is most useful for team members using CLI or IDE
Development Styles
Org based development vs. source driven development.
In a traditional SF Dev Lifecycle, application builders use sandboxes to create and
test changes. Source of truth is either production or any sandbox containing
most recent version of code and customization.
With Salesforce DX, you might use source driven development using latest
versions from a centralized source control system like GIT or SVN.
SFDX concepts
SFDX CLI – command line interface tools, for executing commands like
> sfdx force:doc:commands:list
Unlocked packages are intended to provide a repeatable, scriptable and
trackable vehicle for introducing and managing change in your orgs.
Scratch Org is a temporary organization created from DevHub
You can think that this is temporary sandbox of any edition from Developer to
Enterprise, which default lifespan is 7 days and maximum lifespan is 30 days,
which can be set by parameter --durationdays 30
DevHub feature can be enabled on production or tried in SFDX Trial Org [2]
Without scratch org
With scratch org
DevHub options
SFDX CLI is SF CLI
Using SFDX CLI you can use both DX features and standard features.
For example, you can run a SOQL query using CLI
> sfdx force:data:soql:query –q “select id, name from account limit 10” –u production
However, force:source:pull and force:source:push work only with scratch
orgs.
You can create a scratch org by force:org:create command only from DevHub
org – production or trial organization with DevHub feature turned on
Read Release Notes [3] !
They have added ability to write custom plugins if you know Node.js
Authentication
To authenticate into a non-scratch org execute command
> sfdx force:auth:web:login -a alias
This would open a new browser tab where you can login, OAuth credentials will be
stored on local machine.
Find list of custom object on org
> sfdx force:schema:sobject:list -c custom -u alias
Create a record
> sfdx force:data:record:create -s Account -v "Name=Test" –u alias
You can also run Apex tests, retrieve metadata, deploy metadata, create users,
assign permission set etc.
CLI uses Tooling API and Metadata API under hood
DX Project creation
To create a folder with SFDX project
> sfdx force:project:create -n MyNewProject
This would create MyNewProject subfolder in the current folder with SFDX project
structure.
Common files and folder of SFDX project include
sfdx-project.json – contains default project settings
config/project-scratch-def.json – controls shape of scratch org creation
.forceignore – controls source files to omit for push, pull and status commands [4]
force-app/main/default/ - contains source code and configuration metadata
Project settings file
Default content of project settings file sfdx-project.json contains [4]
{
"packageDirectories": [ //source element folder
{
"path": "force-app",
"default": true
}
],
"namespace": "", //possible configuration of namespace
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "42.0“ // default version of created classes, components etc.
}
Scratch org config
Default content of scratch org definition configuration file config/project-scratch-def.json
contains [6]
{
"orgName": "rwinkelmeyer Company",
"edition": "Developer",
"orgPreferences" : {
"enabled": ["S1DesktopEnabled"]
}
}
To create a scratch org with given settings
> sfdx force:org:create -f config/project-scratch-def.json -a MyScratchOrg.
Scratch org config
Disable Lightning session cache in scratch org
{
"orgName": "rwinkelmeyer Company",
"edition": "Developer",
"orgPreferences" : {
"enabled": ["S1DesktopEnabled"],
"disabled": ["S1EncryptedStoragePref2"]
}
}
To create a scratch org with given settings
> sfdx force:org:create -f config/project-scratch-def.json -a MyScratchOrg.
Advanced example https://gist.github.com/bohdandovhan/d5a91c6d9b16c6c90c7670f50832932c
Global or local config
Find configuration setting by using command
> sfdx force:config:list
Set local setting by command
> sfdx force:config:set
Set global setting by command
> sfdx force:config:set -g
Global settings are stored in “.sfdx” folder under your user account, while local
settings are stored in “.sfdx” folder in the project root folder.
Global settings apply to all projects, local settings apply to project where they are
defined.
It is commonly suggested to add “.sfdx” folder to git ignore
Config list output
Output example of command sfdx force:config:list
=== Config
NAME VALUE LOCATION
───────────────────── ───────────── ────────
defaultdevhubusername DevHub Global
defaultusername GeoAppScratch Local
SFDX Source Control
Three commands to work with sources, similar to git commands
To push local source files to scratch org, use force:source:push command
To pull source files from scratch org to local folder, use force:source:pull
To determine source status, use force:source:status command
However, force:source:pull and force:source:push work only with scratch
orgs.
Once you run force:source:status command, it’ll detect which files have changed
(from a Salesforce DX perspective) since your last pull or push. This is
extremely helpful for detecting remotely changed files, especially when you
have changed the same file locally. The pull and push commands provide a —
forceoverwrite flag which you can then use to enforce (as the name says) an
overwrite for a changed file.
Development Cycle
1. Create a new scratch org and push existing code to it (or start with a new
project from scratch).
2. Develop live in the scratch org and test changes.
3. Pull the changes down to the local machine.
4. Change some components locally.
5. Push the components and validate the work in the org.
6. Commit the changes to git (never forget that scratch orgs expire, so make sure
your code is in version control).
CI with DX Config
1. Install Salesforce CLI on the CI host.
2. Obtain or create a digital certificate to secure your connection to the Salesforce
org. (self-signed certificates work OK)
3. Create and configure a Connected App in your Dev Hub org.
4. Authorize your Salesforce CI user to access this Connected App.
5. Configure a Salesforce JWT (JSON Web Tokens) authentication flow. This
allows the CI host to securely perform headless (without human interactivity)
operations on your Dev Hub org.
Trailhead module to try CI with DX using Travis [7]
CI with DX
What can or should be done with DX CI?
Create a fresh scratch org for test run
Run Apex Tests sfdx force:apex:test:run -w 10 -c -r human
Run Lightning Lint sfdx force:lightning:lint
./path/to/lightning/components/
Run Lightning Testing Service [8]
Install LTS: sfdx force:lightning:test:install
Run: sfdx force:lightning:test:run -a jasmineTests.app
Clean up test environment
CI with DX
What can or should be done with DX CI?
> sfdx force:lightning:lint force-app/main/default/aura —verbose —exit && /
> sfdx force:org:create -w 10 -s -f config/project-scratch-def.json -a ciorg && /
> sfdx force:source:push && /
> sfdx force:apex:test:run -c -r human -w 10
> sfdx force:org:delete -u ciorg -p
CD with DX
DX Continuous delivery options
1. Unlocked packages (second generation packages)
2. Managed packages
3. Metadata API
Create unlocked package version
Deprecated sfdx force:package2:version:create
Use: sfdx force:package:version:create
Update unlocked package version
Deprecated sfdx force:package2:version:update
Use: sfdx force:package:version:update
Install sfdx force:package:install
MP and Metadata API
Create managed package version
sfdx force:package1:version:create /
-i $packageId /
-n "v$releaseVersion" /
-v "$releaseVersion" /
--managedreleased
-w 10
Metadata API Deployment
mkdir mdapi_temp_dir
sfdx force:source:convert -d mdapi_temp_dir
sfdx force:mdapi:deploy -d mdapi_temp_dir/
-u $targetOrg -w 10
rm -fr mdapi_temp_dir
Data Tree Migration
Export data tree data
sfdx force:data:tree:export -q "SELECT Name, Location__Latitude__s,
Location__Longitude__s FROM Account WHERE Location__Latitude__s != NULL AND
Location__Longitude__s != NULL" -d ./data
Import data tree data
sfdx force:data:tree:import --plan data/sample-data-plan.json
SFDX allows to migrate both metadata and data
However, not too much of data, it is not complete replacement for
DataLoader [9]
Files creation
SFDX CLI has commands to create empty apex class, trigger, visualforce page,
component and lightning component.
sfdx force:apex:class:create -n DebugClass -d classes
sfdx force:apex:class:create -n CustomException -d classes -t ApexException
sfdx force:apex:class:create -n TestDebug -d classes -t ApexUnitTest
sfdx force:apex:class:create -n EmailService -d classes -t InboundEmailService
sfdx force:apex:trigger:create -n AccTrigger -s Account -e 'before insert, after update'
sfdx force:visualforce:page:create -n Page -l Label -d pages
sfdx force:visualforce:component:create -n comp -l compLabel -d components
sfdx force:lightning:app:create create a Lightning app
sfdx force:lightning:component:create create a Lightning component
sfdx force:lightning:event:create create a Lightning event
sfdx force:lightning:interface:create create a Lightning interface
sfdx force:lightning:test:create create a Lightning test
Files Pecularities
SFDX CLI has commands to create empty apex class, trigger, visualforce page,
component and lightning component.
However, all other components like SObjects, Fields, Tabs should be created
manually and then pulled from scratch organization
Each custom object field is a separate file. Each element in zipped static resource
is a separate file.
No destructiveChanges.xml is needed, just delete the source file, push and it will
be deleted from scratch organization
Limits
How many activetotal scratch orgs can I have in my edition?
EE – 40, UE, PerfE – 100, Trial – 20 active scratch orgs.
EE – 80, UE, PerfE – 200, Trial – 40 daily scratch orgs allocations.
Edition Active Scratch
Org Allocation
Daily Scratch
Org Allocation
Enterprise
Edition
40 80
Unlimited
Edition
100 200
Performance
Edition
100 200
Dev Hub trial 20 40
Limits
How many active scratch orgs do I
currently have?
Execute command
sfdx force:limits:api:display
-u DevHub
Source conversion
How do I convert my existing source to DX?
First, you need to create a project
sfdx force:project:create -n super_awesome_dx_project
Place a folder with old source in project folder, then execute commands
sfdx force:mdapi:convert -r mdapipackage/
I have a DX project but I want to use ANT Migration Tool. How do I convert DX project
back to ANT migration Tool format?
Easy. Just execute commands
mkdir mdapioutput
sfdx force:source:convert -d mdapioutput/
ANT Tasks in DX
Can I deploy ant project with DX?
Yes. Definitely, just run a command
sfdx force:mdapi:deploy -d mdapioutput/ -w 100
You might want to specify alias for target deployment organization with -u flag.
How do I perform ANT Retrieve task with DX?
Retrieve package
sfdx force:mdapi:retrieve -s -r ./mdapipackage -p DreamInvest -u org -w 10
Retrieve unpackaged source
sfdx force:mdapi:retrieve -k package.xml -r testRetrieve -u org
Licenses support DX
After you’ve enabled Dev Hub capabilities in an org, you’ll need to create user
records for any members of your team who you want to allow to use the Dev
Hub functionality, if they aren’t already Salesforce users. Three types of
licenses work for Salesforce DX users:
Salesforce,
Salesforce Platform
and the new Salesforce Limited Access license.
Permissions needed
To give full access to the Dev Hub org, the permission set must contain these
permissions.
Object Settings > Scratch Org Info > Read, Create, and Delete
Object Settings > Active Scratch Org > Read and Delete
Object Settings > Namespace Registry > Read, Create, and Delete
To work with second-generation packages in the Dev Hub org, the permission set
must also contain:
System Permissions > Create and Update Second-Generation Packages
Referenceshttps://developer.salesforce.com/blogs/2018/02/getting-started-salesforce-dx-part-1-
5.html
https://developer.salesforce.com/promotions/orgs/dx-signup
https://developer.salesforce.com/media/salesforce-cli/releasenotes.htm
https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm
https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm
https://trailhead.salesforce.com/modules/sfdx_travis_ci
https://github.com/forcedotcom/LightningTestingService
https://salesforce.stackexchange.com/questions/221991/sfdx-datasoqlquery-fails-
on-significant-amount-of-data
https://developer.salesforce.com/docs/atlas.en-
us.sfdx_setup.meta/sfdx_setup/sfdx_setup_add_users.htm

More Related Content

PPT
SFDX - Spring 2019 Update
PPT
Custom Metadata Records Deployment From Apex Code
PPT
SFDX Presentation
PPTX
Sfdx introduction
PPTX
Gradle,the new build system for android
PPTX
Exploring the power of Gradle in android studio - Basics & Beyond
PPTX
MAX 2008 - Building your 1st AIR application
PPTX
Migrating from MFC to Qt
SFDX - Spring 2019 Update
Custom Metadata Records Deployment From Apex Code
SFDX Presentation
Sfdx introduction
Gradle,the new build system for android
Exploring the power of Gradle in android studio - Basics & Beyond
MAX 2008 - Building your 1st AIR application
Migrating from MFC to Qt

What's hot (19)

PDF
Gradle plugins, take it to the next level
PDF
Gradle plugin, take control of the build
PDF
React Ecosystem
PDF
Basic Gradle Plugin Writing
PDF
Cocoapods Overview - library dependency manager for iOS
PDF
Java 9 and Beyond
PDF
Idiomatic Gradle Plugin Writing
PPSX
Java 9 and the impact on Maven Projects (Devoxx 2016)
PPTX
React inter3
PDF
Idiomatic gradle plugin writing
PDF
C&S APIs in IBM Notes and Domino
PDF
Lightweight Developer Provisioning with Gradle
PPTX
Android presentation - Gradle ++
PDF
Developing modern java web applications with java ee 7 and angular js
PPTX
React nativebeginner1
PDF
Instrumentación de entrega continua con Gitlab
PDF
Intelligent Projects with Maven - DevFest Istanbul
PPTX
もう知らずにはいられないGitOpsをArgoCDで学ぶ【WESEEK Tech Conf #3】
Gradle plugins, take it to the next level
Gradle plugin, take control of the build
React Ecosystem
Basic Gradle Plugin Writing
Cocoapods Overview - library dependency manager for iOS
Java 9 and Beyond
Idiomatic Gradle Plugin Writing
Java 9 and the impact on Maven Projects (Devoxx 2016)
React inter3
Idiomatic gradle plugin writing
C&S APIs in IBM Notes and Domino
Lightweight Developer Provisioning with Gradle
Android presentation - Gradle ++
Developing modern java web applications with java ee 7 and angular js
React nativebeginner1
Instrumentación de entrega continua con Gitlab
Intelligent Projects with Maven - DevFest Istanbul
もう知らずにはいられないGitOpsをArgoCDで学ぶ【WESEEK Tech Conf #3】
Ad

Similar to Salesforce Developer eXperience (SFDX) (20)

PPTX
Comment utiliser Visual Studio Code pour travailler avec une scratch Org
PPTX
Créer et gérer une scratch org avec Visual Studio Code
PPTX
Salesforce DX for admin
PPTX
Salesforce DX (Meetup du 11/10/2017)
PPTX
Salesforce DX for Admin v2
PDF
sfdx continuous Integration with Jenkins on aws (Part II)
PPTX
Salesforce Apex Hours:- Salesforce DX
PPTX
Get started with Salesforce DX
PPTX
NAD19 - Create an org with Salesforce DX without Code
PPTX
FTD19 - Salesforce DX with "Visual Studio code"
PDF
Lean Drupal Repositories with Composer and Drush
PDF
Android develop guideline
PDF
Salesforce DX ことはじめ
PPT
An introduction to maven gradle and sbt
PPTX
OpenStack Rally presentation by RamaK
PPTX
CICD With GitHub, Travis, SonarCloud and Docker Hub
PPTX
Getting started with Salesforce DX & CLI
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
PDF
Openshift cheat rhce_r3v1 rhce
PDF
Salesforce CLI Cheat Sheet
Comment utiliser Visual Studio Code pour travailler avec une scratch Org
Créer et gérer une scratch org avec Visual Studio Code
Salesforce DX for admin
Salesforce DX (Meetup du 11/10/2017)
Salesforce DX for Admin v2
sfdx continuous Integration with Jenkins on aws (Part II)
Salesforce Apex Hours:- Salesforce DX
Get started with Salesforce DX
NAD19 - Create an org with Salesforce DX without Code
FTD19 - Salesforce DX with "Visual Studio code"
Lean Drupal Repositories with Composer and Drush
Android develop guideline
Salesforce DX ことはじめ
An introduction to maven gradle and sbt
OpenStack Rally presentation by RamaK
CICD With GitHub, Travis, SonarCloud and Docker Hub
Getting started with Salesforce DX & CLI
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Openshift cheat rhce_r3v1 rhce
Salesforce CLI Cheat Sheet
Ad

More from Bohdan Dovhań (11)

PPTX
PUBLISHING YOUR PACKAGE TO APPEXCHANGE IN 2023
PPTX
Second-generation managed packages
PPT
Migrate To Lightning Web Components from Aura framework to increase performance
PPT
Sdfc forbidden and advanced techniques
PPTX
SFDC REST API
PPTX
Being A Salesforce Jedi
PPT
Salesforce REST API
PPT
Salesforce certifications process
PPT
Salesforce for marketing
PPT
Introduction about development, programs, saas and salesforce
PPT
ExtJS Sencha Touch
PUBLISHING YOUR PACKAGE TO APPEXCHANGE IN 2023
Second-generation managed packages
Migrate To Lightning Web Components from Aura framework to increase performance
Sdfc forbidden and advanced techniques
SFDC REST API
Being A Salesforce Jedi
Salesforce REST API
Salesforce certifications process
Salesforce for marketing
Introduction about development, programs, saas and salesforce
ExtJS Sencha Touch

Recently uploaded (20)

PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
L1 - Introduction to python Backend.pptx
PDF
medical staffing services at VALiNTRY
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Reimagine Home Health with the Power of Agentic AI​
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Oracle Fusion HCM Cloud Demo for Beginners
17 Powerful Integrations Your Next-Gen MLM Software Needs
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Salesforce Agentforce AI Implementation.pdf
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
L1 - Introduction to python Backend.pptx
medical staffing services at VALiNTRY
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Complete Guide to Website Development in Malaysia for SMEs
Navsoft: AI-Powered Business Solutions & Custom Software Development
Reimagine Home Health with the Power of Agentic AI​
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Download FL Studio Crack Latest version 2025 ?
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Wondershare Filmora 15 Crack With Activation Key [2025
Why Generative AI is the Future of Content, Code & Creativity?
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx

Salesforce Developer eXperience (SFDX)

  • 2. Introduction Bohdan Dovhan Senior Salesforce Developer Salesforce Development Team Lead Salesforce Certified Platform Developer I Salesforce Certified Platform Developer II Salesforce Certified Platform App Builder 8 years of Development experience 5 years of Development on Salesforce platform
  • 3. What is SFDX? SFDX is both a new set of tools and new features affecting development lifecycle. SFDX helps to shift source of truth from production org to VCS repository. SFDX is an opportunity to shift the source of truth management and org development lifecycle [1] SFDX is most useful for team members using CLI or IDE
  • 4. Development Styles Org based development vs. source driven development. In a traditional SF Dev Lifecycle, application builders use sandboxes to create and test changes. Source of truth is either production or any sandbox containing most recent version of code and customization. With Salesforce DX, you might use source driven development using latest versions from a centralized source control system like GIT or SVN.
  • 5. SFDX concepts SFDX CLI – command line interface tools, for executing commands like > sfdx force:doc:commands:list Unlocked packages are intended to provide a repeatable, scriptable and trackable vehicle for introducing and managing change in your orgs. Scratch Org is a temporary organization created from DevHub You can think that this is temporary sandbox of any edition from Developer to Enterprise, which default lifespan is 7 days and maximum lifespan is 30 days, which can be set by parameter --durationdays 30 DevHub feature can be enabled on production or tried in SFDX Trial Org [2]
  • 9. SFDX CLI is SF CLI Using SFDX CLI you can use both DX features and standard features. For example, you can run a SOQL query using CLI > sfdx force:data:soql:query –q “select id, name from account limit 10” –u production However, force:source:pull and force:source:push work only with scratch orgs. You can create a scratch org by force:org:create command only from DevHub org – production or trial organization with DevHub feature turned on Read Release Notes [3] ! They have added ability to write custom plugins if you know Node.js
  • 10. Authentication To authenticate into a non-scratch org execute command > sfdx force:auth:web:login -a alias This would open a new browser tab where you can login, OAuth credentials will be stored on local machine. Find list of custom object on org > sfdx force:schema:sobject:list -c custom -u alias Create a record > sfdx force:data:record:create -s Account -v "Name=Test" –u alias You can also run Apex tests, retrieve metadata, deploy metadata, create users, assign permission set etc. CLI uses Tooling API and Metadata API under hood
  • 11. DX Project creation To create a folder with SFDX project > sfdx force:project:create -n MyNewProject This would create MyNewProject subfolder in the current folder with SFDX project structure. Common files and folder of SFDX project include sfdx-project.json – contains default project settings config/project-scratch-def.json – controls shape of scratch org creation .forceignore – controls source files to omit for push, pull and status commands [4] force-app/main/default/ - contains source code and configuration metadata
  • 12. Project settings file Default content of project settings file sfdx-project.json contains [4] { "packageDirectories": [ //source element folder { "path": "force-app", "default": true } ], "namespace": "", //possible configuration of namespace "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "42.0“ // default version of created classes, components etc. }
  • 13. Scratch org config Default content of scratch org definition configuration file config/project-scratch-def.json contains [6] { "orgName": "rwinkelmeyer Company", "edition": "Developer", "orgPreferences" : { "enabled": ["S1DesktopEnabled"] } } To create a scratch org with given settings > sfdx force:org:create -f config/project-scratch-def.json -a MyScratchOrg.
  • 14. Scratch org config Disable Lightning session cache in scratch org { "orgName": "rwinkelmeyer Company", "edition": "Developer", "orgPreferences" : { "enabled": ["S1DesktopEnabled"], "disabled": ["S1EncryptedStoragePref2"] } } To create a scratch org with given settings > sfdx force:org:create -f config/project-scratch-def.json -a MyScratchOrg. Advanced example https://gist.github.com/bohdandovhan/d5a91c6d9b16c6c90c7670f50832932c
  • 15. Global or local config Find configuration setting by using command > sfdx force:config:list Set local setting by command > sfdx force:config:set Set global setting by command > sfdx force:config:set -g Global settings are stored in “.sfdx” folder under your user account, while local settings are stored in “.sfdx” folder in the project root folder. Global settings apply to all projects, local settings apply to project where they are defined. It is commonly suggested to add “.sfdx” folder to git ignore
  • 16. Config list output Output example of command sfdx force:config:list === Config NAME VALUE LOCATION ───────────────────── ───────────── ──────── defaultdevhubusername DevHub Global defaultusername GeoAppScratch Local
  • 17. SFDX Source Control Three commands to work with sources, similar to git commands To push local source files to scratch org, use force:source:push command To pull source files from scratch org to local folder, use force:source:pull To determine source status, use force:source:status command However, force:source:pull and force:source:push work only with scratch orgs. Once you run force:source:status command, it’ll detect which files have changed (from a Salesforce DX perspective) since your last pull or push. This is extremely helpful for detecting remotely changed files, especially when you have changed the same file locally. The pull and push commands provide a — forceoverwrite flag which you can then use to enforce (as the name says) an overwrite for a changed file.
  • 18. Development Cycle 1. Create a new scratch org and push existing code to it (or start with a new project from scratch). 2. Develop live in the scratch org and test changes. 3. Pull the changes down to the local machine. 4. Change some components locally. 5. Push the components and validate the work in the org. 6. Commit the changes to git (never forget that scratch orgs expire, so make sure your code is in version control).
  • 19. CI with DX Config 1. Install Salesforce CLI on the CI host. 2. Obtain or create a digital certificate to secure your connection to the Salesforce org. (self-signed certificates work OK) 3. Create and configure a Connected App in your Dev Hub org. 4. Authorize your Salesforce CI user to access this Connected App. 5. Configure a Salesforce JWT (JSON Web Tokens) authentication flow. This allows the CI host to securely perform headless (without human interactivity) operations on your Dev Hub org. Trailhead module to try CI with DX using Travis [7]
  • 20. CI with DX What can or should be done with DX CI? Create a fresh scratch org for test run Run Apex Tests sfdx force:apex:test:run -w 10 -c -r human Run Lightning Lint sfdx force:lightning:lint ./path/to/lightning/components/ Run Lightning Testing Service [8] Install LTS: sfdx force:lightning:test:install Run: sfdx force:lightning:test:run -a jasmineTests.app Clean up test environment
  • 21. CI with DX What can or should be done with DX CI? > sfdx force:lightning:lint force-app/main/default/aura —verbose —exit && / > sfdx force:org:create -w 10 -s -f config/project-scratch-def.json -a ciorg && / > sfdx force:source:push && / > sfdx force:apex:test:run -c -r human -w 10 > sfdx force:org:delete -u ciorg -p
  • 22. CD with DX DX Continuous delivery options 1. Unlocked packages (second generation packages) 2. Managed packages 3. Metadata API Create unlocked package version Deprecated sfdx force:package2:version:create Use: sfdx force:package:version:create Update unlocked package version Deprecated sfdx force:package2:version:update Use: sfdx force:package:version:update Install sfdx force:package:install
  • 23. MP and Metadata API Create managed package version sfdx force:package1:version:create / -i $packageId / -n "v$releaseVersion" / -v "$releaseVersion" / --managedreleased -w 10 Metadata API Deployment mkdir mdapi_temp_dir sfdx force:source:convert -d mdapi_temp_dir sfdx force:mdapi:deploy -d mdapi_temp_dir/ -u $targetOrg -w 10 rm -fr mdapi_temp_dir
  • 24. Data Tree Migration Export data tree data sfdx force:data:tree:export -q "SELECT Name, Location__Latitude__s, Location__Longitude__s FROM Account WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL" -d ./data Import data tree data sfdx force:data:tree:import --plan data/sample-data-plan.json SFDX allows to migrate both metadata and data However, not too much of data, it is not complete replacement for DataLoader [9]
  • 25. Files creation SFDX CLI has commands to create empty apex class, trigger, visualforce page, component and lightning component. sfdx force:apex:class:create -n DebugClass -d classes sfdx force:apex:class:create -n CustomException -d classes -t ApexException sfdx force:apex:class:create -n TestDebug -d classes -t ApexUnitTest sfdx force:apex:class:create -n EmailService -d classes -t InboundEmailService sfdx force:apex:trigger:create -n AccTrigger -s Account -e 'before insert, after update' sfdx force:visualforce:page:create -n Page -l Label -d pages sfdx force:visualforce:component:create -n comp -l compLabel -d components sfdx force:lightning:app:create create a Lightning app sfdx force:lightning:component:create create a Lightning component sfdx force:lightning:event:create create a Lightning event sfdx force:lightning:interface:create create a Lightning interface sfdx force:lightning:test:create create a Lightning test
  • 26. Files Pecularities SFDX CLI has commands to create empty apex class, trigger, visualforce page, component and lightning component. However, all other components like SObjects, Fields, Tabs should be created manually and then pulled from scratch organization Each custom object field is a separate file. Each element in zipped static resource is a separate file. No destructiveChanges.xml is needed, just delete the source file, push and it will be deleted from scratch organization
  • 27. Limits How many activetotal scratch orgs can I have in my edition? EE – 40, UE, PerfE – 100, Trial – 20 active scratch orgs. EE – 80, UE, PerfE – 200, Trial – 40 daily scratch orgs allocations. Edition Active Scratch Org Allocation Daily Scratch Org Allocation Enterprise Edition 40 80 Unlimited Edition 100 200 Performance Edition 100 200 Dev Hub trial 20 40
  • 28. Limits How many active scratch orgs do I currently have? Execute command sfdx force:limits:api:display -u DevHub
  • 29. Source conversion How do I convert my existing source to DX? First, you need to create a project sfdx force:project:create -n super_awesome_dx_project Place a folder with old source in project folder, then execute commands sfdx force:mdapi:convert -r mdapipackage/ I have a DX project but I want to use ANT Migration Tool. How do I convert DX project back to ANT migration Tool format? Easy. Just execute commands mkdir mdapioutput sfdx force:source:convert -d mdapioutput/
  • 30. ANT Tasks in DX Can I deploy ant project with DX? Yes. Definitely, just run a command sfdx force:mdapi:deploy -d mdapioutput/ -w 100 You might want to specify alias for target deployment organization with -u flag. How do I perform ANT Retrieve task with DX? Retrieve package sfdx force:mdapi:retrieve -s -r ./mdapipackage -p DreamInvest -u org -w 10 Retrieve unpackaged source sfdx force:mdapi:retrieve -k package.xml -r testRetrieve -u org
  • 31. Licenses support DX After you’ve enabled Dev Hub capabilities in an org, you’ll need to create user records for any members of your team who you want to allow to use the Dev Hub functionality, if they aren’t already Salesforce users. Three types of licenses work for Salesforce DX users: Salesforce, Salesforce Platform and the new Salesforce Limited Access license.
  • 32. Permissions needed To give full access to the Dev Hub org, the permission set must contain these permissions. Object Settings > Scratch Org Info > Read, Create, and Delete Object Settings > Active Scratch Org > Read and Delete Object Settings > Namespace Registry > Read, Create, and Delete To work with second-generation packages in the Dev Hub org, the permission set must also contain: System Permissions > Create and Update Second-Generation Packages
  • 33. Referenceshttps://developer.salesforce.com/blogs/2018/02/getting-started-salesforce-dx-part-1- 5.html https://developer.salesforce.com/promotions/orgs/dx-signup https://developer.salesforce.com/media/salesforce-cli/releasenotes.htm https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm https://trailhead.salesforce.com/modules/sfdx_travis_ci https://github.com/forcedotcom/LightningTestingService https://salesforce.stackexchange.com/questions/221991/sfdx-datasoqlquery-fails- on-significant-amount-of-data https://developer.salesforce.com/docs/atlas.en- us.sfdx_setup.meta/sfdx_setup/sfdx_setup_add_users.htm