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

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='',
emailencodingkey='UTF-8', firstName='First', lastname='Last', languagelocalekey='en_US',
localesidkey='en_US', profileid =,
timezonesidkey='Europe/London', username='');

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.