In this post, We will try to understand how to reset or set a password using Execute Anonymous. At times we want to set or reset a password for some generic users or admin users. We can use System.setpassword() method provided by Salesforce to achieve the desired result from developer console.
Steps to Execute:
- Login to Salesforce
- Click on setup and Select Developer Console
- From Developer console, Navigate to Debug and select Open Execute Anonymous Window
- Enter System.setpassword command as shown in the screenshot
- Click on Execute
System.setPassword(User,password);
user–Enter the 15 digit or 18 digit userid of the desired user
password — Enter the desired password for the user
Setup–> Developer Console–>Debug –> Open Execute Anonymous Window–>Setpassword method–>Execute
Pro Tip: Developer Console caches your previous settings so once you reset it remove the command from the Developer console and execute it. If someone else ever logs in as you and opens developer console they will see the command and password. For this reason, we want to remove the command from developer console once the password is reset.