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
Devendra SawantDevendra Sawant 

Create New User

 

Hi,

 

How can i create new user using Visualforce page?

 

What is the code to do it the same?

 

Cheers,

Devendra S

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

Yes! I think you need to create a custom picklist to show it as a picklist instead of lookup because its behavior is also same and you can not change the value once selected.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

Ankit AroraAnkit Arora

This is not helpful?

 

http://boards.developerforce.com/t5/Apex-Code-Development/Create-New-User/m-p/311337

 

Let me know if there is any problem using this.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Devendra SawantDevendra Sawant

 

Hi,

 

I am creating visualforce page to create New User using standard controller.

The page is displaying all other fields exceot User Type.

I have also created one record, by default it has got Salesforce as Usertype(User License).

Why the visualforce page is not displaying User Type field?

Cheers,
Devendra S

Ankit AroraAnkit Arora

Are you trying to do something like this ??

 

<apex:page standardController="User">
<apex:form>
    <apex:inputField value="{!User.UserType}"/>
</apex:form>
</apex:page>

 

If yes then it is displaying me the value, and if not then please post your code here.

 

Thanks

Ankit Arora

 Blog | Facebook | Blog Page

Devendra SawantDevendra Sawant

Hi,

 

I am using the following VF code,

 

 

<apex:page standardController="User">
  <apex:sectionHeader title="User Creation" subtitle="{!User.Name}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="User Assignment" mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value=" Save "></apex:commandButton>
                    <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>
                 </apex:pageBlockButtons>
             
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
                  <apex:inputField value="{!User.FirstName}"/>
                  <apex:inputField value="{!User.LastName}"/>
                  <apex:inputField value="{!User.Username}"/>
                  <apex:inputField value="{!User.Email}"/>
                  <apex:inputField value="{!User.alias}"/>
                  <apex:inputField value="{!User.UserRoleId}"/> 
                  <apex:inputField value="{!User.IsActive}"/>
                  <apex:inputField value="{!User.UserType}"/>
                  <apex:inputField value="{!User.ProfileId}"/>
                   <apex:inputField value="{!User.Phone}"/>
                   <apex:inputField value="{!User.Extension}"/>
                   <apex:inputField value="{!User.Fax}"/>
                   <apex:inputField value="{!User.EmployeeNumber}"/>
                   <apex:inputField value="{!User.Title}"/>
                   <apex:inputField value="{!User.CompanyName}"/>
                   <apex:inputField value="{!User.Division}"/>
                   <apex:inputField value="{!User.Department}"/>
                   <apex:inputField value="{!User.CommunityNickName}"/>
                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.UserType}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>
                   <apex:inputField value="{!User.User_Skills__c}" />
              </apex:pageBlockSection>
              </apex:pageBlock>
              </apex:form>            
</apex:page>

 

I am using the same statement as you have mentioned,

 

I am getting the User Type as a text, but it is not displaying the picklist.

 

Cheers,

Devendra S

Ankit AroraAnkit Arora

Indeed! Once you have selected the user type on user then you can nor change it.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Devendra SawantDevendra Sawant

 

Hi,

 

It is not displaying the picklist to select Usertype(User license).

 

One more thing I am getting lookup field in front of user, profile field. Where as in standard functionality these fields gives Picklist. How can i get picklist here too.

 

 

Cheers,

Devendra S

Ankit AroraAnkit Arora

Yes! I think you need to create a custom picklist to show it as a picklist instead of lookup because its behavior is also same and you can not change the value once selected.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
Devendra SawantDevendra Sawant

 

Hi,

 

If i create a custom picklist to replace lookup, then i will have to use extensions to bind those picklist with the data.

 

Please correct me if i am wrong.

 

Cheers,

Devendra S

Ankit AroraAnkit Arora

Yes you need to create extension for it.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Devendra SawantDevendra Sawant

Hi,

 

On my visual force page, UserType field is not visble

 

I have used this statement : <apex:inputField value="{!User.UserType}"/>  but UserType field is not visible.

 

In standard User functionality UserType and Profile are picklist. Profile  picklist is depend on UserType/UserLicense. How to handle those dependency between fields? How can i convert lookup box into the picklist?

 

Cheers,

Devendra S