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

wheather its possible to create user using controller extension using own save method

Hello All,


whether its possible to ctrate user using custom pages and controller extensions using own save method?





Yes. Quick example:



<apex:page standardController="Account" extensions="MyExt"> <apex:pageBlock> <apex:pageBlockButtons> <apex:commandButton value="Overridden save" action="{!mySaveOverride}" /> <apex:commandButton value="Normal save" action="{!save}" /> </apex:pageBlockButtons> <!-- REST OF PAGE HERE--> </apex:pageBlock> </apex:page>


Controller extension


public class MyExt { public Account acct { get;set; } public ApexPages.StandardController controller { get;set; } public MyExt(ApexPages.StandardController stdController) { this.controller = stdController; this.acct = (Account)stdController.getRecord(); } public PageReference mySaveOverride() { // do something here // and then call : return; // or do something like update acct, after doing your logic, // in that case, end with: return this.controller.view(); // or another valid page reference } }



hi ,

i have written the controller using user as u said.but for my case it is not storing the records.I dont know why .Could you help me if posible....




<apex:page standardController="User" extensions="usercontroller" >

<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="User Information">
<apex:inputField id="userFirstName" value="{!user.firstname}"/>
<apex:inputField id="userLastName" value="{!User.lastName}"/>
<apex:inputField id="userAlias" value="{!User.alias}"/>
<apex:inputField id="userEmail" value="{!}"/>
<apex:inputField id="userUserName" value="{!User.UserName}"/>
<apex:inputField id="userLicense" value="{!User.UserType}"/>
<apex:inputField id="userEmailEncoding" value="{!user.title}"/>
<apex:inputField id="userCommunityNickName" value="{!User.communityNickName}"/>
<apex:inputField id="userrole" value="{!User.UserRoleId}"/>
<apex:inputField id="userProfileId" value="{!User.ProfileId}"/>
<apex:inputField id="userEmailEncodingKey" value="{!User.EmailEncodingKey}"/>
<apex:inputField id="userlanguage" value="{!User.LanguageLocaleKey}"/>
<apex:inputField id="userlocale" value="{!User.LocaleSidKey}"/>
<apex:inputField id="userTimezone" value="{!User.TimeZoneSidKey}"/>

<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="cancel"/>


My Apex class:

public class usercontroller {


public User cntr{


    public usercontroller(ApexPages.StandardSetController controller) {


 public ApexPages.StandardController controller {

    public usercontroller(ApexPages.StandardController controller) {

         this.controller = controller;

    cntr= (User )controller.getRecord();



public PageReference Test()
        PageReference pageRef = new  PageReference('');
         return pageRef ;

public PageReference Save()

        PageReference pageRef = new  PageReference('');
         return pageRef ;






Devendra SawantDevendra Sawant



I am facing the same problem.


Have you got the answer for this??


Please let me know.



Devendra S