Search In This Blog

2016-09-28

Changing a user's email address without confirmation.

When try to change user's email, Salesforce will send a confirmation mail to new email address and a notification mail to old email address in security purpose.But sometimes user don't want to get further notifications.

To avoid send notification mail to old email, try ways follow. (All ways are no working with owner)

Way 1. Set Setup | Manage | User Management | Users
When change the email address, "Generate new password and notify user immediately" checkbox (at the bottom of the edit screen) need to be checked. Then the email address will get committed right away, no more confirmation needed! But obviously the user then gets sent a new password.


Way 2. Change email through Develop console
1.Select user data [select id,email,username from user]
2.Change the target user's email and click [Save Rows]
3.Click [Refresh Grid] to check if email is been changed.
*(2016/09/28) Some license may not working, like "Company Communities".


Way 3. Change email by code
User user = [select id,email from user where id = 'target user id'];
user.email = 'new_email@exmple.com';
update user;
*If use upsert, it will have a error: "DML not allowed on User". No matter if the record already exists or updating or creating new
*(2016/09/28) Some lisence may not working, like "Company Communities"
*(2021/11/5 update) Looks like Salesforce had removed Way 3 completely.

3 comments:

  1. way 3 doesn't work, it still sends the confirmation email to new user.
    Is there any other way to modify the email without user confirmation

    ReplyDelete
  2. +1 to the previous comment - is there truly no way to change the email immediately with Apex?

    ReplyDelete
    Replies
    1. Were you able to find any solution to change the email immediately with Apex without sending confirmation link email?

      Delete