Salesforce, Python, SQL, & other ways to put your data where you need it

Need event music? 🎸

Live and recorded jazz, pop, and meditative music for your virtual conference / Zoom wedding / yoga class / private party with quality sound and a smooth technical experience

Quick -- I need a blank scratch org

11 May 2023 🔖 salesforce
💬 EN

Table of Contents

Whew! As I prepare to talk about subflows (sign up now!), I’m working my way through old usernames and passwords to Salesforce dev orgs and realizing they’ve mostly expired, now that I no longer work the old job to which all the reminder emails were being sent.

I don’t want to clutter up the one I found that still works, so instead of playing around with configuration inside of it, I’d like to use it merely as a “hub” from which to spin up a “scratch org” that will live for 7 days (perfect – I only have 6 to get the presentation ready!).

I can’t remember a darned thing about what to do, so I figured I might as well live-blog the process of retracing my steps.

Make sure the dev org is a dev hub

I went to and got myself signed into the dev org.

Then I opened up Setup, searched for Dev Hub, and made sure it was enabled (it was).

I also took note of the server that my dev org was associated with: “examplecom-d9-dev-ed.”

Double-check my CLI tool installation status

I double-checked whether I have the SFDX and CumulusCI CLI tools installed with the following 2 commands:

cci --version
sfdx --version

Interestingly, I didn’t have the SFDX CLI tool installed. It must be that the only project I’d ever worked on from this computer is downloading copies of object and field configuration out of long-lived orgs, which doesn’t involve scratch orgs at all and therefore only needs the CumulusCI CLI tool, not the SFDX CLI tool. So I installed it and now sfdx --version works.

Log the SFDX CLI into my dev org

I already noted that my dev org was associated with the Salesforce server “examplecom-d9-dev-ed.”

I think I’ll “alias” the dev org “my-last-remaining-dev-org” in my SFDX CLI context.

That means running this command to log my computer’s copy of the SFDX CLI tool into my dev org and nickname the logged-in state “my-last-remaining-dev-org”:

sfdx force:auth:web:login --setalias my-last-remaining-dev-org --instanceurl

This command confirms I logged SFDX in correctly:

sfdx auth:list

Create a new folder on my computer

When it’s been a while, I always think I need to create a new empty C:\example\ folder on my computer from scratch and Git-track it and hand-add various files to it, but no, that’s not correct.

The better way to do things is to create a new C:\example\ folder on my computer with a copy of my Salesforce CumulusCI project minimum viable build in it, update the sourceApiVersion in C:\example\sfdx-project.json to 57.0, update the to “subflow-202305 and” to “Subflow 2023-05 presentation” in C:\example\cumulusci.yml, and replace “CumulusCI Minimum Viable Build to make a scratch org” with “Subflow 2023-05 presentation” in each of the 4 .json files under C:\example\orgs.

OK, done.

Tell my folder what dev org to use as a dev hub

Per my CumulusCI Minimum Viable Build article, I created a new file (and “.sfdx” subfolder of C:\example\ to hold it) at C:\example\.sfdx\sfdx-config.json and put the following content into it:

    "defaultdevhubusername": "my-last-remaining-dev-org"

Now whenever I run any CumulusCI CLI commands I run out of a C:\example\ context that have to do with creating or deleting scratch orgs, the CCI CLI tool will authenticate into my dev org as a “dev hub” for doing so.

Create a scratch org

OK, now I can create a 7-day-lifespan org nicknamed “dev” within the C:\example\ context using the following command:

cci flow run dev_org --org dev

And I can log my web browser into that scratch org and start configuring things with the following command:

cci org browser --org dev --url-only

Do everything else

And so on and so forth – other handy commands for synchronizing what I do in the web browser back and forth with C:\example are in myCumulusCI Minimum Viable Build article.

Since it seems I end up Googling myself every time I forget how to use SFDX, CCI, or scratch orgs…

--- ---