7

I want to do a demo next week and want to check that the scratch org I'll be using for the demo won't have expired by that date. How can I do this?

6 Answers 6

14

The sfdx force:org:display command can also show the expiration date:

david$ sfdx force:org:display -u test-<snipped>@example.com

=== Org Description
KEY              VALUE
───────────────  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Access Token     <snipped>
Client Id        SalesforceDevelopmentExperience
Created By       <snipped>
Created Date     2018-05-20T13:28:07.000+0000
Dev Hub Id       <snipped>
Edition          Enterprise
Expiration Date  2018-05-27
Id               00D3B0000004g6wUAA
Instance Url     https://momentum-platform-973.cs50.my.salesforce.com
Org Name         David Company
Status           Active
Username         <snipped>
1
  • Looks the better approach!
    – Keith C
    May 20, 2018 at 14:06
7

Just took me a while Googling to find this so posting here for posterity.

This SFDX command will provide the information:

sfdx force:org:list --all

Here is an example of the output (with STATUS and EXPIRATION DATE over on the right):

ALIAS             SCRATCH ORG NAME  USERNAME                       ORG ID              STATUS   EXPIRATION DATE
────────────────  ────────────────  ─────────────────────────────  ──────────────────  ───────  ───────────────
                  UX                [email protected]  00Df0000001oLtdEAE  Expired  2018-03-20
vscodeScratchOrg  UX                test-fm[email protected]  00D3D0000000h8SUAQ  Active   2018-05-24
7

I apologize for the late answer. You can use a SOQL query like the following:

sfdx force:data:soql:query -q "SELECT Name, OrgName, Edition, CreatedDate, ExpirationDate, ScratchOrg, Status FROM ScratchOrgInfo" -u DevHub

The DevHub from the command above would be the name you have given to your devhub. You can find out more about the ScratchOrgInfo object at https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_scratchorginfo.htm.

5

Login to your Scratch org, go to the SF Developer Console, open the 'Organization' object, add TrialExpirationDate field to Query and click 'Execute'.

TrialExpirationDate field

Result

2

It's also visible if you log into your Dev Hub org, and then go to the Scratch Org Infos tab.

In one way, this is better than using the CLI because it also lists scratch orgs that were not created via the CLI. e.g. I have some that I created using the Gearset deployment tool. They're not visible when I list via the CLI, but they are visible in the Scratch Org Infos from my Dev Hub.

1

When you authenticate to a scratch using sfdx auth:web:login the, sfdx force:org:display or sfdx force:org:list --all won't display the expired date but, you can use a SOQL query like:

> sfdx force:data:soql:query -q "SELECT TrialExpirationDate FROM Organization" -u devHub
TRIALEXPIRATIONDATE
────────────────────────────
2021-04-08T14:47:48.000+0000

The devHub from the command above would be the target username. More info here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .