Hello Everyone !
"Salesforce Apex Hours" is a recurring event to talk about salesforce ! Some times we'd like to meet on one location and some time online.
This time we are planning one online session on "Salesforce DX" with Jitendra Zaa (Salesforce MVP).
Agenda :-
Salesforce DX provides you with an integrated, end-to-end lifecycle designed for high-performance agile development. In this session we would go through hands on and see how Salesforce DX can be used to create scratch org, automated testing and data load purpose. We would discuss CLI option as well Force.com IDE
• Introduction to Salesforce DX
• Creating Scratch Org
• Deploying metadata to Scratch Org
• Creating Skeleton Workspace
• Running Test classes
• Getting Help
• Using Force.com IDE with Salesforce DX
• Q&A
ICT role in 21st century education and it's challenges.
Salesforce Apex Hours:- Salesforce DX
1. Farmington Hills Salesforce Developer User
Group
Salesforce Apex Hours :-Salesforce DX
#SalesforceApexHours #FarmingtonHillsSFDCDug
Speaker :- Jitendra Zaa (Salesforce MVP), Amit Chaudhary
Date :- Saturday, JUNE 10, 2017 11:00 AM EST
Venue/Link :- Online
2. Who am I ?
Amit Chaudhary
• Active on Salesforce Developer Community
• Blogging at http://amitsalesforce.blogspot.in/
• Co-Organizer of :- FarmingtonHillsSFDCDug
4. Agenda
▶ Introduction to Salesforce DX
▶ Creating Scratch Org
▶ Deploying metadata to Scratch Org
▶ Creating Skeleton Workspace
▶ Running Test classes
▶ Getting Help
▶ Using Force.com IDE with Salesforce DX
▶ Q&A
5. What is Salesforce Dx
▶ New tool to manage deployment life cycle
▶ SCM driven
▶ Package based development
▶ Scratch Org
▶ CLI & Force.com support
6. How to get Salesforce Dx
▶ Its in Pilot
▶ Will go to Beta and then GA after Pilot
▶ Your Org may already have access
▶ Wait for Beta or GA
7. Installation
▶ Install Salesforce CLI from here - https://developer.salesforce.com/media/salesforce-
cli/sfdx-windows-amd64.exe
Get Force.com IDE
https://developer.salesforce.com/media/force-ide/sfdx/pilot/force-ide-Pilot-
win32.win32.x86_64.zip
9. Developer Hub Org
▶ The Developer Hub org is used to authorize all Salesforce DX users. The Developer Hub
(Dev Hub) org is a central location for Salesforce DX because it allows you to create,
delete, and manage your Salesforce scratch orgs.
10. Clone - https://github.com/forcedotcom/sfdx-simple
Run all commands in sfdx-simple folder
Authorize your hub org using below command
sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-devhub-
org
Above command will open browser and we would need
to enter username and password of developer hub account
Authorize Developer Hub Org
11. To Create a scratch Org, we need to have following json
{
"Company": "Cognizant",
"Country": "US",
"LastName": "Zaa",
"Email": "jitendra.Zaa@cognizant.com",
"Edition": "Developer",
"OrgPreferences" : {
"S1DesktopEnabled" : true
}
}
All supported org preferences can be found in Metadata Settings documentation.
Creating Scratch Org
13. To open scratch Org, run below command
sfdx force:org:open
Open Scratch Org
14. This JSON contains information about Salesforce Dx project
{
"PackageDirectories": [
{
"Path": "force-app"
}
],
"Namespace": "",
"SourceApiVersion": "39.0"
}
Push Metadata to scratch Org (sfdx-workspace.json)
15. As per “sfdx-workspace.json” in previous slide, below command will take metadata from
force-app folder and move to scratch org. On successful completion, it will show below
message
sfdx force:source:push
Moving changes to Scratch Org
16. ▶ Below command will create skeleton of DX project workspace with json and folder
structures
sfdx force:workspace:create --workspacename mywork
OR
sfdx force:workspace:create --workspacename mywork --defaultpackagedir
myapp
Create Salesforce DX workspace from CLI
17. sfdx force:apex:test:run
Above command will return Job Id, use that Job Id to get report of test result
sfdx force:apex:test:report -i <ID>
Run Apex test from CLI
18. ▶ Run below command to get the list of all Scratch Org that has been authorized by SFDX
sfdx force:org:list
List all Scratch Org
19. Running below command shows all Top level topics
Sfdx --help
We can get help for each topic by using --help again at topic level like
Sfdx force --help
We can further get help of subtopic using command –help
Sfdx force:alias --help
Getting Help
20. ▶ SalesforceDx logs are saved at
USER_HOME_DIR/.sfdx/sfdx.log
▶ Its running log, and only errors are logged by default
▶ Logs can be changed either with each command or globally
▶ To change at each command, use --loglevel DEBUG
▶ To set log level globally use
set SFDX_LOG_LEVEL=DEBUG (windows)
Or
Export SFDX_LOG_LEVEL=DEBUG (Unix)
SalesforceDx logs
21. Available Log levels in Salesforce Dx
1. ERROR
2. WARN
3. INFO
4. DEBUG
5. TRACE
22. ▶ Salesforce DX creates scratch Org and stores Oauth token internally, It does not provides
password. We can generate password by running below command
sfdx force:user:password:generate
▶ To see generated password again in future , use below command
sfdx force:org:describe
Generating Password of Scratch Org