We have created a new sandbox for training purpose so we have a solid amount of users to change email addresses and reset password.

However, from my understanding, we can only reset the password for users after they have clicked on the confirm email change link in their change email emails.

This is a bit tedious step for training customers. Is there a way we can prevent this from happening?

1 Answer 1


A little known trick my manager taught me is that you can skip the extra step by doing the following:

  • Click Edit on the User
  • Change the Email on the User
  • Check "Generate new password and notify user immediately"
  • Save the User

At this point, the user will receive an email at the new address with a password reset link. This is the "trick" we use internally when we need to fix a user in a Sandbox. You should also be able to trigger this in Apex by using the appropriate DmlOptions value.

  • This approach works very well. But I am struggling to find the relevant dmloption. I tried the following: Database.DMLOptions dlo = new Database.DMLOptions(); dlo.EmailHeader.triggerUserEmail= true; u.setOptions(dlo); But doesn't seem to work well. Is there any suggestion on which dml option should I be using?
    – Lance Shi
    Commented Mar 4, 2019 at 3:42
  • @LanceShi I haven't tried it, but editing the user and resetting in the same transaction should trigger the same way as the UI. However, it does work manually for sure, if you write a script you could use a headless browser to automate mass resets.
    – sfdcfox
    Commented Mar 4, 2019 at 5:38
  • I have tried a few but failed to reset the user password in such a manner. However, I managed to set the default user name for those users which can serve as a walkaround for me. Thank you for that.
    – Lance Shi
    Commented Mar 4, 2019 at 5:56

You must log in to answer this question.

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