Skip to main content

Command Palette

Search for a command to run...

Setting a Salesforce User Password via Developer Console (Apex)

Updated
1 min read
Setting a Salesforce User Password via Developer Console (Apex)

If you would like to quickly set a temporary password for a user, you can do so in the Developer Console.

  1. Get the user via a query (you can use a more specific WHERE clause; in my case, I am just querying based on the user’s name)

     SELECT Id FROM User WHERE Name = 'argen'
    

    Developer Console > Query Editor > Execute

    Developer Console > Query Editor > Execute

  2. Copy the Id from the query result and paste the following Apex code into the Anonymous Window (or simply run CTRL + E if you are on Windows or CMD + E if you are on Mac).

     String userId = '005***************'; // In your case, you will paste the full Id.
     String tempPassword = 'tempPassword123!'; // Password we set for the user.
     System.setPassword(userId, tempPassword);
    

    Click the “Execute” button at the bottom right.

  3. You can log in with the new password. Please follow this approach only in Sandbox or Development environments. Also, make sure the user is active and not frozen.

16 views