Error while creating Scratch Org in VS Code [You do not have access to the [ScratchOrgInfo] object]

Published by

on


Hello Ohana,

I was trying to complete this trail using my free dev org. But I got a strange error while creating the scratch org. So, after spending 5 mins, I found the solution. So, lets save our 5 mins 😉

Steps to create a Scratch Org:

  1. In Visual Studio Code, press Ctrl + Shift + P.
  2. Type sfdx.
  3. Select SFDX: Create a Default Scratch Org….
  4. Press Enter to accept the default project-scratch-def.json.
  5. Press Enter to accept the default trailhead scratch org alias.
  6. Press Enter to accept the default 7 days scratch org duration.

Error: You do not have access to the [ScratchOrgInfo] object

RCA: So basically, you haven’t enabled scratch org feature in your org

You need to Enable Dev Hub to:

  1. Create and manage scratch orgs from the command line
    Scratch orgs are disposable Salesforce orgs that are used to support development and testing. They are fully configurable, allowing developers to emulate different Salesforce editions with different features and preferences.
  2. View information about your scratch orgs
    Information includes details about requested scratch orgs, including whether they are active, expired or deleted.
  3. Link namespace orgs
    You can link namespace orgs to the Dev Hub for using scratch orgs with namespaces.

Steps to Enable Dev Hub:

  1. Go to Setup
  2. Search ‘Dev Hub’
  3. Toggle the ‘Enable Dev Hub’ Switch to make this Enabled
  4. All set, 😊

Note: You can’t disable this feature once enabled.