+ Start a Discussion

Facing problem with password email ??

i am creating user record through apex ..

using following code :


Profile p = [select id from Profile where name='Standard User'];

User u = new User(alias = 'utest', email='kiran_machhewar@persistent.co.in',
emailencodingkey='UTF-8', firstName='First', lastname='Last', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.id,
timezonesidkey='Europe/London', username='kiran_machhewar1234@persistent.co.in');

insert u;



but i am nor receiving password reset link ??

can i set my password in code itself ??

Rakesh KumarRakesh Kumar
If you wanna reset User password then you can use below code

System.resetPassword(user.Id, true);

this will reset the password and sent a message to given User

cant we set our default passord here itself ??

Yes - check the System class out:


This has set and reset password methods.