I was under the impression that the Username field on the User object is globally unique. In other words, even if a value is used in some other instance, that means I cannot create a User record with that same value. Whether sandbox or production, an instance is an instance.

The documentation seems to back up this belief (emphasis mine):



Create, Filter, Group, idLookup, Sort, Update

Required. Contains the name that a user enters to log into the API or the user interface. The value for this field must be in the form of an email address. It must also be unique across all organizations. If you try to create or update a User with a duplicate value for this field, the operation is rejected.

Each inserted User also counts as a license. Every organization has a maximum number of licenses. If you attempt to exceed the maximum number of licenses by inserting User records, the create is rejected.

However, today I wanted to quickly create a User in our full sandbox, so I exported the record I wanted from our production instance, then inserted it in the sandbox, all using Data Loader. I only realized after I clicked Finish to fire off the job, that I had forgotten to change the Username. I was sure I had set myself back when, to my surprise, the insert succeeded. The two records had the same Username, and the operation was allowed.

Was my understanding incorrect? Is it only unique in tandem with the Organization.IsProduction value? Is this behavior a bug?

Since Eric deleted his answer, Salesforce itself claims the behavior is as I expected (emphasis mine):

All Salesforce usernames are unique, for all users, across all Organizations (including Trial Orgs, Production orgs and Sandboxes).

  • yes it is. Even among portals
    – Eric
    Jan 5, 2017 at 3:55
  • @Eric So...bug?
    – Adrian Larson
    Jan 5, 2017 at 3:55
  • Someone recently posted a screenshot of the login prompt with an error message that their username wasn't unique. I think it might have been @daniel-hoechst Jan 5, 2017 at 3:57
  • @AdrianLarson - You are speaking about the Salesforce login UserName correct? It could be a bug or I am also misunderstanding it as well. I know in practice I have not been able to set the username to one previously used..
    – Eric
    Jan 5, 2017 at 3:57
  • 1
    @Eric That link is answer-worthy imo, since it explicitly states that the distinction between sandbox and production should not break uniqueness. Can't promise I'll accept, but definitely worth an up-vote. :)
    – Adrian Larson
    Jan 5, 2017 at 4:08

1 Answer 1


Salesforce is split across login "domains." Each domain uses its own username index, which means it's entirely possible to create the exact same user on login.salesforce.com, test.salesforce.com, and prerellogin.pre.salesforce.com, and any other unique login domains that may exist. Note that "My Domain" does not constitute a unique login domain; it still participates in the primary login domain. Additionally, portal users in some types of portals can have the same user name in different organizations. So, this means that you can't, for example, have a developer edition org and production org that both use the same username, but you can have the same username in production and one of your sandbox orgs. If you try to set the same username in a second sandbox, you'd still get a unique username error.

  • 2
    So basically we should submit feedback on that document that it is incorrect? Is the documentation anywhere aligned with this assessment of platform behavior?
    – Adrian Larson
    Jan 5, 2017 at 4:27
  • 2
    Well aint that a kick in the pants.....Maybe it is the wording of the doc that is being misread. Maybe it should be "Across all organization of the same domain". Maybe that is what they meant and interpreted it to say
    – Eric
    Jan 5, 2017 at 4:28
  • 1
    @AdrianLarson Yes. I don't know who wrote that doc, but it's wrong. In fact, I just logged in to one of my sandboxes, and set it to the same username as my primary developer edition org, just to verify that it's still true. It was true 11+ years ago when I started, it's true now.
    – sfdcfox
    Jan 5, 2017 at 4:29
  • 3
    Well, I gave the article a thumbs down and explained why it's wrong. Excuse me while I go hold my breath waiting for them to fix it.
    – Adrian Larson
    Jan 5, 2017 at 4:33
  • 3
    As an interesting side note, the uniqueness doesn't appear to be enforced at the database level. @bigassforce created two users with the same username via the Environment Hub. This resulted in a "Your User Name is no longer unique." error on login. See twitter.com/bigassforce/status/816332983267430404 Jan 5, 2017 at 18:43

You must log in to answer this question.

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