When a guest user tries to register for the community with an existing email address, he gets following error. Your request cannot be processed at this time. The site administrator has been alerted.

enter image description here

I wanted this error to be customized to a meaningful error like Username already exists. But unfortunately, I couldn't find any source or tip to change the error message. Then I created a custom lightning-web-component with custom Apex Controller. Now, when an user registers, I want to create an user that is linked to the Account which is configured at the community's login & registration section.

How do you get the configured accountId and profileId in apex controller or is there any better approach?


Account Id and Profile Id are not required to be specified when creating a community user via a custom selfRegisterController

User u = new User();
u.FirstName = 'FisrtName';
u.LastName = 'LastName';
// no need to specify profileId
Site.createExternalUser(u, NULL); // pass null for account Id

Then salesforce will automatically identify relevant Account Id and Profile Id as long as you have configured it in community settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.