Salesforce Dev Projects Setup & Change Tracking
High-Level Steps:
- Clean Up Connected/Authenticated Orgs as Needed
sfdx org list
- Delete Unneeded Scratch orgs from the Dev Hub org: App Launcher > “Active Scratch Orgs”
- Set Up a New Salesforce DX Project
sfdx org login web -d -a DevHub
sfdx force:project:create -n NameTBD
- VS Code command:
SFDX: Create a Default Scratch Org
- VS Code command:
SFDX: Set a default org
sfdx org open
- Set Up Source Control on GitHub
- See Below
- Make Configuration Changes and Pull Down Source
sfdx force source pull
- As Needed, Push the Source into New Scratch Orgs
sfdx force source push
- To Migrate Data to/from the Scratch Org using DataLoader, Make Sure You Have Password for Default Admin User
sfdx force:user:password:generate --target-org <username>
sfdx org:display --target-org <username>
Detailed Steps:
1. Clean Up Connected/Authenticated Orgs As Needed
- View all connected orgs with
sfdx org list
(formerlysfdx force:org:list
). - Mark (some of your) your scratch orgs for deletion with
sfdx org list --clean
. - In the Dev Hub org, go to App Launcher > “Active Scratch Orgs.” Use the list to delete any unneeded scratch orgs.
- To remove other orgs showing up under
sfdx org list
, delete the JSON files located at~/.sfdx
on your local machine.
2. Set Up a New Salesforce DX Project
- Create a new Trailhead Playground and get its credentials. Ex: [email protected]
- Via Setup > Quick Find > “Dev” > Dev Hub. Then Enable Dev Hub.
- Create an alias DevHub (
-a DevHub
) and make it the default org (-d
) viasfdx org login web -d -a DevHub
. Use the credentials from previous steps to log in. - Create an empty directory to hold the Salesforce DX project created in the next step.
- From the empty directory created above, create a project called JobApplications via:
sfdx force:project:create -n NameTBD
cd
into the newly created folder.- Create a new scratch org within VS Code via:
CTRL-SHIFT-P
then using commandSFDX: Create a Default Scratch Org
.
Use thesfdx-project.json
file and a 30 day duration.
Or, use the command:sfdx force:org:create -s -f config/project-scratch-def.json -a --durationdays 30 NameTBD
. Either command should set the new scratch org as the default. - Switch between scratch orgs with the command
SFDX: Set a default org
. - Log into the scratch org with
sfdx org open
. Since the scratch org was set as default using-s
the system stores the authentication token and uses it log in for you.
Note: You can also confirm the successful creation and linking of the scratch org from your Dev Hub org from App Launcher > Active Scratch Orgs
sfdx-project.json
:
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"name": "JobApplications",
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "57.0"
}
3. Set Up Source Control on GitHub
- Set up a new GitHub repository from github.com/new.
cd
into the project folder.- Follow the usual steps GitHub provides to create a new
git
repository on the command line:echo "# jobapplications" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/<your_github_username>/<github-repository-name>
- If you are using personal access tokens, retrieve the access token, then use
git remote set-url origin https://<github-token>@github.com/<username>/<repository-name>.git
, replacing<github-token>
with the access token git push origin main
- Use the usual steps to add changes, commit them, and push them to GitHub:
git add .
git commit -m "Some message"
git push origin main
4. Make Configuration Changes and Pull Down Source
- Make any configuration changes needed using declarative tools.
- Sync changes made in the scratch org to local DX project via
sfdx source pull
. - Use the usual steps to add changes, commit them, and push them to GitHub:
git add .
git commit -m "Some message"
git push origin main
5. As Needed, Push the Source into New Scratch Orgs
- The command
sfdx force source push
will push the source code into the default scratch org.
6. To Migrate Data to/from the Scratch Org using DataLoader, Make Sure You Have Password for Default Admin User
- Use the command
sfdx force:user:password:generate --target-org <username>
to generate a password for the admin user - Thereafter, use the command
sfdx org:display --target-org <username>
to see the password