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);

Your Answer

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

Browse other questions tagged or ask your own question.