Friday, June 1, 2012

Change Password via Developer Console in Salesforce without resetting password

Scenario:
      We need to reset a password or change the password on an user utilizing a 3rd party app in salesforce. This user is there for the app only and not really a physical user in the instance. The email for this user is a person who has left the company or is on vacation but you need the app to work.

Solution:
    You can do this 2 ways:

  1. Change the Email of the user in question
  2. Click on Generate Password and click save.
But lets say you can not change the Email of the user because you should not be the owner of the app or you are not part of the app as an admin. Here is where you change using Developer Console.

Go to Setup and Drop it down to Developer Console or sometimes called the System Log




Within the "Logs" tab you will see a button called "Execute".


Click on the text box or white space next to it.

It shall open up another window which is titled "Enter Apex Code"

Place in the following SOQL query:
User usr = [select Id from User where username='test@learn4sfdc.com'];
System.setPassword(usr.Id,'test1234');


Then click on Execute.
It should bring up a success window and you should be good to go.
Now you may need to log in and make sure everything is ok.

No comments:

Post a Comment