2

I'm experiencing an odd issue that only applies when my VF page and controller is executed from the Community context. The code allows the user to select an Applicant Contact from a VF page and click a button to have a new Community User created for them.

The overall logic to insert the User works perfectly. The record is created as expected. However, I've been unable to get it to send the 'New Password' email while running in Community context (i.e., logging in as a Community User or selecting the Community from the menu at the top of the page). If I'm logged in normally, the New Password email is sent just fine.

I've tried 3 different methods to get this to work:

  • DMLOptions (dmo.EmailHeader.triggerUserEmail = true). There are no errors in the log, but nothing gets sent.
  • system.resetPassword(u.Id, True): This works fine when logged in normally, but generates a "INVALID_SESSION_ID: This session is not valid for use with the API" error if logged into the Community.
  • Site.forgotPassword (u.UserName): Also works fine if logged in normally, but does nothing if logged into the Community. Again, absolutely nothing in the debug log (even with filters at FINEST). The log just shows a METHOD_ENTRY to forgotPassword followed by METHOD_EXIT.

Has anyone else run into a similar situation and/or is there a work around for this?

I've been thinking about making a callout to a VF page running on a Force.com Site in the org, passing the new UserID. Then that VF page (presumably not running in the Community Context) would be able to make the resetPassword() or forgotPassword() call.

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.