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
Ishan K SharmaIshan K Sharma 

Create user via vf page

Hi

 

I want to create new user on the button click on my vf page. What should be the logic in my controller. Any advice

 

Thanks

Ishan Sharma

Ashish_SFDCAshish_SFDC

Hi Ishan,

 

The easiest way is to add the Create New User Link in the Button.
Go to | Setup | Administration Setup | Manage Users| Users | Click New User Button | Now copy the URL and use it in your Button to Redirect.

 

Regards,
Ashish

Ishan K SharmaIshan K Sharma

Thanks for reply

 

I want to insert a record for user. I want to know is it possible via apex controller.

 

Prafull G.Prafull G.
It is possible via apex controller Ishan. What Ashish mentioned is also the way where you can redirect to standard new User screen and populate necessary information to create user record.

If you do not want to use standard new user functionality and keen to use apex controller then use the following code snippet

User u = new User();
// Set all mandatory parameters i.e. First Name, Last Name, Profile Id etc
insert u;

Let us know if you are looking for more details.