Wednesday, September 1, 2021

Salesforce Password Reset - Bulk Reset

 Hi Trailblazers!


Many times we find ourselves in a scenario where we may need to reset passwords for multiple users.

The below code is a rough idea of how this could be achieved :

changepassword ch= new changepassword();


public class ChangePassword 
{
    public changepassword()
    {
        List<User> userList = new List<User>();
        userList = [SELECT Id from User WHERE IsActive = true ];
        
		for(User usr : userList)
                {
                      System.setPassword(usr.Id, 'xxxxxxxx');
                      System.debug('DONE: ' + usr.Id);
                }
    }
    
    
}

This can be executed from the developer console.

In the developer console :

  • Select Debug
  • Open Execute in Anonymous Window
Please execute :

changepassword ch= new changepassword();

I have not added an actual password so please update "xxxxxxxx"

Happy Trails!



Generate reports from Opportunities using a Visualforce Page in Salesforce

  Step 1: Create a Visualforce Page Go to the Setup menu in Salesforce. Search for "Visualforce Pages" in the Quick Find box and c...