0

I have created a custom self-registration page for a community in a sandbox. I am using Site.createExternalUser(user, accountId, password) with a null password password parameter to create the portal user.

The user is successfully created but the password email is not being sent to the user. Email deliverability is set correctly. If I manually reset the user password through Setup, then I do receive a password email, so I know there's no issue with email filtering or spam folders.

Has anyone run into this before?

BTW: I am letting the method create the portal account contact, so the only thing that exists before I call the method is the account.

Here is the code that sets up the User object. prf is a customer community profile, cr is a wrapper that holds the portal account Id.

u = new User(
        FirstName = cr.firstName,
        LastName = cr.lastName,
        Username = cr.email,
        Email = cr.email,
        CommunityNickname = nickname,
        ProfileId = prf.Id,
        EmailEncodingKey = 'ISO-8859-1',
        LanguageLocaleKey = 'en_US',
        LocaleSidKey = 'en_US',
        TimeZoneSidKey = 'America/New_York'
);
// Setting a null password will send password email to user
String userId = Site.createExternalUser(u, cr.accountId, null);
6
  • Can you check and make sure email deliverability is turned on? help.salesforce.com/… Commented Aug 28, 2018 at 18:54
  • Yes it is set to All Email. Commented Aug 28, 2018 at 19:45
  • Does the email being used already belong to a contact on the account Id you're using? I would check the documentation and read the User parameter carefully. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Commented Aug 28, 2018 at 20:54
  • No, I'm always using a different email address when I test. Commented Aug 29, 2018 at 1:42
  • Check if profile of the user is in list of community/site "Members" in Administration.
    – Nikolay M.
    Commented Dec 1, 2021 at 7:40

0

You must log in to answer this question.

Browse other questions tagged .