How to force reset Password from backend

Published by

on


Sometimes you need to reset password from backend (i.e from Developer console). To do that, just run below code in anonymous window in Dev Console. Don’t forget to replace the ‘username@test.com’ and ‘CustomPW@1’ with the actual username and password.

Syntax: System.setPassword(userid, password);

Id UserId = [select id from User where username = 'username@test.com'].Id;
system.setPassword(UserId, 'CustomPW@1');