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
Nilesh ManeNilesh Mane 

How can I get the 'Temporary Password '?

Hi, 

I am creating a new User using following code : 

 

Database.DMLOptions dlo = new Database.DMLOptions();

dlo.EmailHeader.triggerUserEmail= true;

 

On inserting the User,an email gets send to User's Email with 'Username' and 'Temporary Password'.

 

I need to get that 'Temporary Password' in my Apex code for further logic.

 

How can I get the 'Temporary Password ' from email???

 

Regards,

Nilesh.

sfdcfoxsfdcfox

You can't. Best you can do is try to set the password using the Web Services API "setPassword()" call, but this will only work if the current user is a system administrator or if you can get a valid session ID for a system administrator.