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
ravi1234.ax1565ravi1234.ax1565 

trigger

 

 hello group ,

 

  can we create a user using trigger, if possible how ,

 

              if not why?

 

                            help full to me if any code references 

      

   thanks for giving reply in advance

 

 

                thanks and regerds

          

Best Answer chosen by Admin (Salesforce Developers) 
Vinit_KumarVinit_Kumar

Yes Ravi,

 

You can create user through Trigger.You need to populate all the mandatory field which is required to create a User record.

 

Use below code in your Apex trigger to create a User record :-

 

User u2 = new User(username='vkumar@chatter.com', firstname='Vinit',
lastname='Kumar', email='vkumar@chatter.com',communityNickname = 'vkumar_sfdc',
alias = 'vkumar123', profileid = '00e90000000nyqv', emailencodingkey='UTF-8',
languagelocalekey='en_US', localesidkey='en_US', timezonesidkey='America/Los_Angeles');
 
insert u2;

 

 

All Answers

Vinit_KumarVinit_Kumar

Yes Ravi,

 

You can create user through Trigger.You need to populate all the mandatory field which is required to create a User record.

 

Use below code in your Apex trigger to create a User record :-

 

User u2 = new User(username='vkumar@chatter.com', firstname='Vinit',
lastname='Kumar', email='vkumar@chatter.com',communityNickname = 'vkumar_sfdc',
alias = 'vkumar123', profileid = '00e90000000nyqv', emailencodingkey='UTF-8',
languagelocalekey='en_US', localesidkey='en_US', timezonesidkey='America/Los_Angeles');
 
insert u2;

 

 

This was selected as the best answer
ravi1234.ax1565ravi1234.ax1565

thanks for giving reply......

 

Ankit AroraAnkit Arora

Don't mark your own post as solution, as I can see the above post helped you so you should mark his post as solution and not yours.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Vinit_KumarVinit_Kumar

Thanks Ankit!!

ravi1234.ax1565ravi1234.ax1565

sorry,

 

      i know but i confused to mark his reply as a solution. after a wrong entry i cant able to edit my mistake.

 

          any way thanks for valuable suggestion...

 

                             thanks and regards.....

 

 

ravi1234.ax1565ravi1234.ax1565

thanks vinith for guiding me to right way