• Anilkumar458
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

Hello All,

 

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

 

Regards

Anilkumar

I am writing my own save method for the user custom page which is created by using the standard controller as a User.

when i am trying to write the controller code that time it is not allowing the use.UserType = cntr.UserType .Giving compilatin Error like 
Error: Compile Error: Field is not writeable: User.UserType at line 51 column 6 

Remaing fields are allowed to write.

Why it is not allowing to compile the controller?

Can anyone phased this situation?

 how can i use for UserType Field.

For more clarity on my problem i am just giving my custom page code and controller code  which is given below.

 

custom user Page :

 

<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="{!User.email}"/>
<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:pageBlockSection>

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

</apex:pageBlock>
</apex:form>
</apex:page>

 

Custom controller:

public class usercontroller {

private User cntr;
private final ApexPages.StandardController controller;

    public usercontroller(ApexPages.StandardSetController controller) {
   
   

    }

 

 //
    public usercontroller(ApexPages.StandardController controller) {


         this.controller = controller;

    cntr= (User )controller.getRecord();

    }

 

   
public PageReference Test()
  
     {
            
        PageReference pageRef = new  PageReference('https://na6.salesforce.com/apex/newuser');
       
         pageRef.setRedirect(true);
         return pageRef ;
      
      
    }  

public PageReference Save()
  
     {
    
     User use = new User();
    
     use.firstname = cntr.firstname;
     use.lastName =cntr.lastName;
     use.alias =cntr.alias;
     use.email =cntr.email;
     use.UserName =cntr.UserName;
     use.UserType =cntr.UserType;
     use.title =cntr.title;
     use.communityNickName =cntr.communityNickName;
     use.UserRoleId =cntr.UserRoleId;
     use.ProfileId =cntr.ProfileId;
     use.EmailEncodingKey =cntr.EmailEncodingKey;
     use.LanguageLocaleKey =cntr.LanguageLocaleKey;
     use.LocaleSidKey =cntr.LocaleSidKey;
     use.TimeZoneSidKey =cntr.TimeZoneSidKey;
    
    
    
    
    
      insert use ;

            
        PageReference pageRef = new  PageReference('https://c.na6.visual.force.com/apex/users');
          pageRef.setRedirect(true);
         return pageRef ;
      
      
    } 

 

}

 

Hi ,

I am using the save method which is written in my controller rather than standard save method.while using my own save method for the filed level validation error messgae it is not at the field or on that page .Instead of that it is showing error message at visual force Error page .So how to show my filed level error message at field itself.

 

so please give me any idea or solution .

 

Thanks in Adv

Anilkumar458

Hello All,

 

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

 

Regards

Anilkumar

Hi All,

 

I have  created a custom object say "A", and provide help text for each fields , but I am not able to display help text hover(orange color ? mark) in my Visualforce page.

 

I have created VF page for object "A". With using <Apex:inputField > , but I unable to display help hover.

 

Please let me know if anyone has any idea.

 

-- Deepak