So it’s time to learn about Scratch Orgs. I know about them, but don’t know HOW to do them.
I have all my VSCode environment set up and I have a Dev Hub. My goal is to get the Dreamhouse App installed on a pre-release org (a few days after the release to Sandboxes).
I google getting started with scratch orgs and find this video https://www.youtube.com/watch?v=RJWZD2qO0Cw. Nope, this does not start at the beginning. It jumps straight to having a config file pre-set. Where do I get a config file? where do I save the config file? when do I set up my git repo?
Next Stop Trailhead https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/set-up-your-salesforce-dx-environment
OK, this is getting somewhere.
Set up the Scratch Org
First step log into the dev hub
sfdx force:auth:web:login -d -a DevHub
I’m following the trailhead because I want the Dreamhouse app, so that starts with a Git Clone so doesn’t help me set up a good process for setting up git in the first place. But it looks like Git Clone does make the folder git enabled, which is good.
Next step is that I connected my local Git folder to my Bitbucket via SourceTree, and checked out a branch to work on. (See my VS Code for Non Developers page to get help on how to do this part). So now we can start working. (Until I have everything set up, and backed up to the cloud, I don’t like to start).
I need to make one change to my project-scratch-def.json file to make it a preview release developer org.
"release": "Preview",
I run the command to create the Scratch Org, with the alias of JMDemo
sfdx force:org:create -s -f config/project-scratch-def.json -a JMDemo
hmm, error.
At this time, we are outside of the preview period. You can create only current release scratch orgs.
Even though I’m within the dates of the preview as specified here https://developer.salesforce.com/docs/atlas.en-us.220.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_version_selection.htm
So I start again without the Preview Org and run the command and I have a scratch org.
Open the scratch org with
sfdx force:org:open
And push the metadata in my folders in my local machine via
sfdx force:source:push
Then assign the perm set and import the data as per the trailhead module so I can get Dreamhouse app up and running.
sfdx force:org:open
And there it is, Dreamhouse app ready to go.
Now, Commit to ensure Git is all nice and clean ready for the next step.
Working on the Scratch Org
As I continue working, each thing I do in the org I use the command
sfdx force:source:pull
Which brings the metadata down to the source on my local machine. It’s good to do this after every main action you perform so you know that any changes you are making in the org are going to be in Source and therefore in a new Scratch Org. Eg I changed my User Name and pulled source but it did not pull the user details, of course, because that is data.
Remember you can just use the UP key to re-type the same command again in the CLI terminal. And use UP UP to get to the next most recent command, and keep on going back further in your commands list.
(Thanks to first learning about enterprise computing on Unix boxes for that trick).
Issues
I had an issue where the pull command gave me the following error.
Entity of type 'CustomApplication' named 'Account' cannot be found
Weird
But this Stack Exchange Post kind of helped, I had to put Account.app in my .forceignore file and then it worked. Weird.
Weird Things
The end goal for me would be to create a scratch org that I am happy using that has all my standard modifications in it (eg as shown in New Salesforce Org).
The default scratch org has way too many features in it and weird settings.
Features not needed (could be developer org standard)
FSL
Analytics
Site dot com
Work dot com
Community
Lightning Bolt
CPQ
Orders
Too many Profiles
Weird Settings
Not Enhanced Profile View, but it does have Enhanced Profile List Views
Scratch Org Missing Features
What Scratch Orgs can’t do, and I would have to set up each time I re-generated the scratch org
Tab Positions (but I will change the App instead).
Profile settings of which Record Types are availble or Default
Enhanced Profile Setup
0 Comments