8

As stated in the title - I created a scratch org and created additional user on it using SFDX. Then after deleting this environment when I try to create user with the same name on another scratch org I keep getting error:

The username "[email protected]" already exists in this or another Salesforce org. Usernames must be unique across all Salesforce orgs.

So, how to delete user (or at least change its name) from a scratch org that I don't have access to anymore?

4
  • "was not found" to me does not seem to imply you need to delete the user from the other org. It seems to imply you are trying to find a user in your new org that does not exist. Can you provide the code you're using that is throwing the error?
    – gNerb
    Feb 5, 2019 at 15:45
  • @gNerb my fault, I pasted wrong error message. Take a look now please. Feb 5, 2019 at 15:48
  • Are you creating the scratch orgs fairly close together? Running sfdx force:org:delete enqueues an org for deletion but it's not necessarily instant.
    – David Reed
    Feb 5, 2019 at 15:53
  • @DavidReed That's what I tought too so I gave it around 12 hours span to perform actual deletion. Is there any information from SF how long it may take? Feb 5, 2019 at 15:56

2 Answers 2

12

Scratch Orgs are deleted asynchronously after you run the delete command (or it expires). It will take some time for that username to be freed up, probably at least 24 hours. You'll need to use a different user name in this case, as there's nothing you or Support can do. In the future, rename the user before deleting the org if you wish to reuse the user name in a different scratch org.

8

In addition to @sfdcfox response (which is technically accurate) , I suggest you do not try to reuse the same username in different scratch orgs, this seems a very bad habit and all your project orgs may get quickly messy, even more if you use CI.

You could for example use some suffix for your scratch org usernames, using your project name and the creation date.

Structure : [email protected]

Example: [email protected]

2
  • Thanks for advice. That's a specific situation I've got here - I plan to use sfdx for teaching purposes and I create users for people who will be logging to SF using those usernames so they shouldn't be random or complicated. Feb 5, 2019 at 16:12
  • 4
    [email protected], then [email protected], are not so complicated :) But if it is for permanent manual tests ... maybe a non-scratch org would be a better option Feb 5, 2019 at 16:34

You must log in to answer this question.

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