3

While building out several custom community portals recently I noticed that the SF userame can have multiple @'s in the username field. Although it forces you to have at least 1 of them, and if you don't the platform says the username must be in the format of an email address.

Image showing email format required for username

But it does not enforce the same validation that it forces on email fields. In particular I can have several @'s throughout the username, but as long as there is at least 1 it doesn't show an error.

Image showing multiple @ in username

Whereas the email field will tell you it is improperly formatted when trying to save it.

Image invalid email address error

Granted the invalid user name says ...in the form of..., rather than Invalid Email Address.

The only reason I could think to allow this behavior is to permit people to use their email addresses as a username when appending a suffix to the email that may have the @ in it to identify what portal a user belongs to. But that seems like a bit of a stretch.

Why does the username field behave this way?

1
  • 4
    I've always been surprised there is an @ restriction at all in the username
    – cropredy
    Aug 15, 2016 at 15:18

1 Answer 1

4

The phrasing "in the form of a valid email address" is somewhat ambiguous. Email address validation is notorious for being A) overly complicated and B) unreliable. The advised methodology for finding out if an email address is valid is to simply send an email to that address. That also tells you if the address is truly owned. But the Username is not intended to be a valid address in all cases, so this approach can't be applied.

It's unlikely you'll get anyone from Salesforce to explain why they implemented the validation the way they did, or what that specific validation might be. As you have found, they take a very loose interpretation of the form of a valid email address for the purpose of the Username field.

1
  • I figured as much, but thought I would ask just to see if I was maybe missing something obvious. Thanks! Aug 15, 2016 at 16:50

You must log in to answer this question.

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