6

When a Community user tries to register using an email address that already exists in the system (using self-registration), they receive a very generic error message:

"Your request cannot be processed at this time. The site administrator has been alerted."

Does anyone know how we can customize this error message (via code or anything else) to rather display something like this:

"Oops! Looks like you're trying to register with an email address that is already associated with a User. Please go back to the login page and log in with the email address and your existing password."

3
  • Have you looked at the registration controller? Do you have a lightning community or a visualforce community? How your user enters the community and registers will greatly affect the answer to your question.
    – crmprogdev
    Jun 20, 2018 at 12:45
  • @crmprogdev I have looked at the lightning registration controller, but I can't see where this error is getting defined or called. It is a lightning community. Any suggestions for how I should edit the standard CommunitiesSelfRegController?
    – JustinF
    Jun 22, 2018 at 5:57
  • @JustinF, remember to accept the answer if it helped you reach a solution so other in the community can use it as a reference. Thanks!
    – glls
    Aug 19, 2018 at 23:27

2 Answers 2

3

Its not in the controller. Since you have a Lightning Community, the error messages are controlled by Lightning Components. See this help page and the image below for more.

Community Login Setup Page

4
  • thanks, while that is useful to know, I'm struggling with what code I need to write to accomplish the solution. I'm not a developer but I am familiar with Apex -- could you please provide some guidance on what the code should look like in the CommunitiesSelfRegController.apxc file to handle a duplicate user error?
    – JustinF
    Jul 1, 2018 at 8:05
  • I don't think you understood my answer. It's the Lightning Component that handles the duplicate user error message, NOT the LightningSelfRegController.
    – crmprogdev
    Jul 1, 2018 at 12:27
  • right, but I don't understand the significance of that? How does that help me with customizing the error? The error is not determined within the .cmp file, but in the controller. The Component only renders the error.
    – JustinF
    Jul 2, 2018 at 10:15
  • The red arrow in the image above is not mine. It was already there. The error itself will come from the Salesforce Servers when they discover an attempt to register a duplicate user name. If you're using SSO, there's a web service that handles that. How it's displayed should be through the component, not the controller, but I could be mistaken.
    – crmprogdev
    Jul 2, 2018 at 14:49
2

I eventually was able to determine the correct solution, though I didn't end up actually implementing it. The steps that needed to be taken were:

  1. Duplicate the existing standard lightning self registration component (this was important -- I thought I could just edit the standard component, but apparently that's not feasible).
  2. In the controller, find the line of code which calls a function to create a user in the system
  3. Before the above-mentioned line of code, use a SOQL query to check if any user exists with the same username (this code should already be written since it is standard)
  4. Wrap that segment of code in a try-catch or if-else statement. Add your custom error message there, such that if the SOQL query returns 1 or more records, your custom error is displayed to the user.
  5. Add your new component to a new community page
  6. Update your Community Administration settings to use your new custom page for registration
  7. Test it out by registering a User with an existing username

That should do the trick!

You must log in to answer this question.

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