You need to sign in to do that
Don't have an account?

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