Pre-Requisites:
1. VS Code.
2. project-scratch-def.json file in VS Code.
{
"orgName": "Demo Company",
"edition": "Developer",
"features": ["Communities", "ServiceCloud"],
"settings": {
"communitiesSettings": {
"enableNetworksEnabled": true
},
"omniChannelSettings": {
"enableOmniChannel": true
}
}
}
Steps to create the scratch org:
1. Use the following command to set the Dev Hub Username for Scratch Orgs.
sfdx force:config:set defaultdevhubusername=<org username>
Example:
sfdx force:config:set [email protected]
[email protected] is my Salesforce Org Username.
Note:
Salesforce CLI generates Usernames for scratch orgs. This is for setting default Dev Hub Org.
2. Use the following command to login and set the Dev Hub org an alias.
sfdx force:auth:web:login -d -a DevHub
3. Use the following command to create the Scratch org.
sfdx force:org:create -f project-scratch-def.json --nonamespace
Use the following command if you get the exception “The force:org:create command is deprecated. Try “org create scratch” or “org create sandbox” instead”.
sf org create scratch --definition-file config/project-scratch-def.json
4. Note down the Org Id and the Username.
5. You can also go to Scratch Org Infos and Active Scratch Orgs tabs to check in the Dev Hub org.