SlideShare une entreprise Scribd logo
1  sur  34
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
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.
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?
1. Create a fresh scratch org for test run
2. Run Apex Tests sfdx force:apex:test:run -w 10 -c -r human
3. Run Lightning Lint sfdx force:lightning:lint
./path/to/lightning/components/
4. Run Lightning Testing Service [8]
a) Install LTS: sfdx force:lightning:test:install
b) Run: sfdx force:lightning:test:run -a jasmineTests.app
5. 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]
Apex class 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 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
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
References1. https://developer.salesforce.com/blogs/2018/02/getting-started-salesforce-dx-part-1-
5.html
2. https://developer.salesforce.com/promotions/orgs/dx-signup
3. https://developer.salesforce.com/media/salesforce-cli/releasenotes.htm
4. https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
5. https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm
6. https://developer.salesforce.com/docs/atlas.en-
us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm
7. https://trailhead.salesforce.com/modules/sfdx_travis_ci
8. https://github.com/forcedotcom/LightningTestingService
9. https://salesforce.stackexchange.com/questions/221991/sfdx-datasoqlquery-fails-
on-significant-amount-of-data
10. https://developer.salesforce.com/docs/atlas.en-
us.sfdx_setup.meta/sfdx_setup/sfdx_setup_add_users.htm

Contenu connexe

Tendances

Tendances (20)

Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
Introduction to Salesforce | Salesforce Tutorial for Beginners | Salesforce T...
 
Best Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfBest Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdf
 
Top Benefits of Salesforce in Business
Top Benefits of Salesforce in BusinessTop Benefits of Salesforce in Business
Top Benefits of Salesforce in Business
 
Manage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkManage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance Framework
 
Best practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on SalesforceBest practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on Salesforce
 
First Steps to Salesforce Release Management & DevOps [Salesforce User Group,...
First Steps to Salesforce Release Management & DevOps [Salesforce User Group,...First Steps to Salesforce Release Management & DevOps [Salesforce User Group,...
First Steps to Salesforce Release Management & DevOps [Salesforce User Group,...
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce Intro
 
DevOps in Salesforce AppCloud
DevOps in Salesforce AppCloudDevOps in Salesforce AppCloud
DevOps in Salesforce AppCloud
 
Webinar: Take Control of Your Org with Salesforce Optimizer
Webinar: Take Control of Your Org with Salesforce OptimizerWebinar: Take Control of Your Org with Salesforce Optimizer
Webinar: Take Control of Your Org with Salesforce Optimizer
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Salesforce.com Sandbox management
Salesforce.com Sandbox management Salesforce.com Sandbox management
Salesforce.com Sandbox management
 
Session 1: INTRODUCTION TO SALESFORCE
Session 1: INTRODUCTION TO SALESFORCESession 1: INTRODUCTION TO SALESFORCE
Session 1: INTRODUCTION TO SALESFORCE
 
Introduction to Salesforce Platform - Basic
Introduction to Salesforce Platform - BasicIntroduction to Salesforce Platform - Basic
Introduction to Salesforce Platform - Basic
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetup
 
Salesforce apex hours azure dev ops
Salesforce apex hours   azure dev opsSalesforce apex hours   azure dev ops
Salesforce apex hours azure dev ops
 
Salesforce Flawless Packaging And Deployment
Salesforce Flawless Packaging And DeploymentSalesforce Flawless Packaging And Deployment
Salesforce Flawless Packaging And Deployment
 
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce IntroductionSalesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
 
Manage Salesforce Like a Pro with Governance
Manage Salesforce Like a Pro with GovernanceManage Salesforce Like a Pro with Governance
Manage Salesforce Like a Pro with Governance
 
Salesforce admin training 1
Salesforce admin training 1Salesforce admin training 1
Salesforce admin training 1
 

Similaire à SFDX Presentation

Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
NicolasVuillamy1
 

Similaire à SFDX Presentation (20)

Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)
 
SFDX - Spring 2019 Update
SFDX - Spring 2019 UpdateSFDX - Spring 2019 Update
SFDX - Spring 2019 Update
 
Comment utiliser Visual Studio Code pour travailler avec une scratch Org
Comment utiliser Visual Studio Code pour travailler avec une scratch OrgComment utiliser Visual Studio Code pour travailler avec une scratch Org
Comment utiliser Visual Studio Code pour travailler avec une scratch Org
 
Créer et gérer une scratch org avec Visual Studio Code
Créer et gérer une scratch org avec Visual Studio CodeCréer et gérer une scratch org avec Visual Studio Code
Créer et gérer une scratch org avec Visual Studio Code
 
Salesforce DX for admin
Salesforce DX for adminSalesforce DX for admin
Salesforce DX for admin
 
Salesforce DX (Meetup du 11/10/2017)
Salesforce DX (Meetup du 11/10/2017)Salesforce DX (Meetup du 11/10/2017)
Salesforce DX (Meetup du 11/10/2017)
 
Sfdx introduction
Sfdx introductionSfdx introduction
Sfdx introduction
 
Salesforce DX for Admin v2
Salesforce DX for Admin v2Salesforce DX for Admin v2
Salesforce DX for Admin v2
 
sfdx continuous Integration with Jenkins on aws (Part II)
sfdx continuous Integration with Jenkins on aws (Part II)sfdx continuous Integration with Jenkins on aws (Part II)
sfdx continuous Integration with Jenkins on aws (Part II)
 
Salesforce Apex Hours:- Salesforce DX
Salesforce Apex Hours:- Salesforce DXSalesforce Apex Hours:- Salesforce DX
Salesforce Apex Hours:- Salesforce DX
 
Get started with Salesforce DX
Get started with Salesforce DXGet started with Salesforce DX
Get started with Salesforce DX
 
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
NAD19 - Create an org with Salesforce DX without Code
NAD19 - Create an org with Salesforce DX without CodeNAD19 - Create an org with Salesforce DX without Code
NAD19 - Create an org with Salesforce DX without Code
 
Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17
 
GradleFX
GradleFXGradleFX
GradleFX
 
Salesforce CLI
Salesforce CLISalesforce CLI
Salesforce CLI
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Operator SDK for K8s using Go
Operator SDK for K8s using GoOperator SDK for K8s using Go
Operator SDK for K8s using Go
 
Build and Distributing SDK Add-Ons
Build and Distributing SDK Add-OnsBuild and Distributing SDK Add-Ons
Build and Distributing SDK Add-Ons
 

Plus de Bohdan Dovhań

Plus de Bohdan Dovhań (12)

PUBLISHING YOUR PACKAGE TO APPEXCHANGE IN 2023
PUBLISHING YOUR PACKAGE TO APPEXCHANGEIN 2023PUBLISHING YOUR PACKAGE TO APPEXCHANGEIN 2023
PUBLISHING YOUR PACKAGE TO APPEXCHANGE IN 2023
 
Second-generation managed packages
Second-generation managed packagesSecond-generation managed packages
Second-generation managed packages
 
Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance
 
Custom Metadata Records Deployment From Apex Code
Custom Metadata Records Deployment From Apex CodeCustom Metadata Records Deployment From Apex Code
Custom Metadata Records Deployment From Apex Code
 
Sdfc forbidden and advanced techniques
Sdfc forbidden and advanced techniquesSdfc forbidden and advanced techniques
Sdfc forbidden and advanced techniques
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
 
Being A Salesforce Jedi
Being A Salesforce JediBeing A Salesforce Jedi
Being A Salesforce Jedi
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
Salesforce certifications process
Salesforce certifications processSalesforce certifications process
Salesforce certifications process
 
Salesforce for marketing
Salesforce for marketingSalesforce for marketing
Salesforce for marketing
 
Introduction about development, programs, saas and salesforce
Introduction about development, programs, saas and salesforceIntroduction about development, programs, saas and salesforce
Introduction about development, programs, saas and salesforce
 
ExtJS Sencha Touch
ExtJS Sencha TouchExtJS Sencha Touch
ExtJS Sencha Touch
 

Dernier

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

SFDX Presentation

  • 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 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.
  • 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? 1. Create a fresh scratch org for test run 2. Run Apex Tests sfdx force:apex:test:run -w 10 -c -r human 3. Run Lightning Lint sfdx force:lightning:lint ./path/to/lightning/components/ 4. Run Lightning Testing Service [8] a) Install LTS: sfdx force:lightning:test:install b) Run: sfdx force:lightning:test:run -a jasmineTests.app 5. 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. Apex class 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 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
  • 27. 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
  • 28. 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
  • 29. Limits How many active scratch orgs do I currently have? Execute command sfdx force:limits:api:display -u DevHub
  • 30. 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/
  • 31. 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
  • 32. 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.
  • 33. 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
  • 34. References1. https://developer.salesforce.com/blogs/2018/02/getting-started-salesforce-dx-part-1- 5.html 2. https://developer.salesforce.com/promotions/orgs/dx-signup 3. https://developer.salesforce.com/media/salesforce-cli/releasenotes.htm 4. https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm 5. https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm 6. https://developer.salesforce.com/docs/atlas.en- us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm 7. https://trailhead.salesforce.com/modules/sfdx_travis_ci 8. https://github.com/forcedotcom/LightningTestingService 9. https://salesforce.stackexchange.com/questions/221991/sfdx-datasoqlquery-fails- on-significant-amount-of-data 10. https://developer.salesforce.com/docs/atlas.en- us.sfdx_setup.meta/sfdx_setup/sfdx_setup_add_users.htm