function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ForceComForceCom 

System.resetpassword() not working correctly ?

HI , 

 

I have the below code , which is a part of the code that i am working on. I am able to retrieve the user  record , user Id and also contact Id . When I try to use the system.resetpassword(), it gives me an unknown exception with error Id, it is wierd  as it seems , since the system.resetpassword() tends to work correctly when i test this method in developer console , it does reset the password. Any help would be greatly appreciated.

 

Map<Id,User> usermap= new Map<Id,User>([Select Id,ContactId from User where ContactId IN: contactIdset]);

system.debug('reset password entered');
if(usermap.size()>0){

for(User user1:usermap.Values()){
system.debug('user id'+user1.Id);
system.debug('contact Id '+user1.ContactId);
system.resetPassword(user1.Id,true);

}
}

 

Thanks