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
viv1viv1 

how to Create Users record through apex ??

how to Creating Users record not customer portal user through apex ?? is it possible ??

 

bob_buzzardbob_buzzard

You can do this - here's an example I put together and tested via anonymous apex for another thread I was helping on:

 

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

 User u = new User(alias = 'utest', email='Unit.Test@unittest.com',
                 emailencodingkey='UTF-8', firstName='First', lastname='Last', languagelocalekey='en_US',
                 localesidkey='en_US', profileid = p.id,
                 timezonesidkey='Europe/London', username='Unit.Test@unittest.com');

insert u;

 

viv1viv1

thnx its working fine..

i cant find user license field there ??

it by defaults create salesforse license user ...cant we change license ??

bob_buzzardbob_buzzard

The license is tied to the profile - choose a profile that has that particular license type.

viv1viv1

Thanks !! got it...

viv1viv1
  1.  i am able to create user..
  2. but i am not receiving the password link ??
  3.  can i set some by default password ??
bob_buzzardbob_buzzard
Check out the System class:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_system.htm

This has reset and set password capabilities.