I am having issues passing through the VFP & Controller a Custom Field. Mimicing the process for Standard Fields, I can pass anything through without an issue.

Visualforce Code:

<apex:page id="communitiesSelfRegPage" showHeader="true"   standardStylesheets="false" controller="CommunitiesSelfRegController" title="{!$Label.site.user_registration}">
<apex:define name="body">
         <apex:form id="theForm" forceSSL="true">
  <apex:pageMessages id="error"/>                    
 <apex:pageBlock mode="mainDetail" >  
74171 <apex:pageBlockSection columns="1" >

                  <div class="requiredInput"><div class="requiredBlock"></div>
                  <apex:inputText required="true" id="firstName" value="{!firstName}" label="*First Name"/>                     
                  <apex:inputText required="true" id="lastName" value="{!lastName}" label="*Last Name"/>
                  <apex:inputText required="true" id="CompanyName" value="{!CompanyName}" label="*Company Name"/>
                  <apex:inputText required="false" id="Client_ID_c" value="{!Client_ID_c}" label="*Client ID"/>
                  <apex:inputText required="true" id="Division" value="{!Division}" label="*Division"/>
                  <apex:inputText required="true" id="Title" value="{!Title}" label="*Title"/>
                  <apex:inputText required="true" id="Country" value="{!Country}" label="*Country"/>
                  <apex:inputText required="true" id="State" value="{!State}" label="*State"/>
                  <apex:inputText required="true" id="Phone" value="{!Phone}" label="*Phone"/>
                  <apex:inputText required="true" id="email" value="{!email}" label="*Email (Username)"/>
                  <apex:selectlist value="{!Role_c}" multiselect="false" size="1" label="What is your role?">
                    <apex:selectOption itemValue="" itemLabel=""/>
                    <apex:selectOption itemValue="Primary Functional Contact" itemLabel="Primary Functional Contact"/>
                    <apex:selectOption itemValue="Primary Technical Contact" itemLabel="Primary Technical Contact"/>
                    <apex:selectOption itemValue="Alternate Functional Contact" itemLabel="Alternate Functional Contact"/>
                    <apex:selectOption itemValue="Alternate Technical Contact" itemLabel="Alternate Technical Contact"/>
                    <apex:selectOption itemValue="Other" itemLabel="Other"/>
                  <apex:inputCheckbox required="false" id="Enable_Notifications_c" value="{!Enable_Notifications_c}"></apex:inputCheckbox>
                      <apex:outputLabel ><p>Sign me up for Service Notifications.</p>
                          <p>(Note that email notifications are sent for scheduled and unscheduled maintenance, service interruptions and general announcements.</p>
                  <apex:inputCheckbox required="false" id="Agree_to_Terms_and_Conditions_c" value="{!Agree_to_Terms_and_Conditions_c}"></apex:inputCheckbox>

                  <apex:outputLabel ><p><strong>Submit your desired password (max 8 characters)</strong></p>
                  <apex:pageBlockSectionItem helpText="Minimum of 8 characters.  Must mix alpha, numeric, and special characters." >
                  <apex:outputLabel value="{!$Label.site.password}" for="password"/>
                  <apex:inputSecret id="password" value="{!password}"/>
                  <apex:inputSecret id="confirmPassword" value="{!confirmPassword}" label="*Confirm Password"/>
                  <apex:outputText value=""/>
                  <apex:commandButton style="position: relative; background:#757575; color:#fffffd; padding:10px 20px; border:0px solid #444554;" action="{!registerUser}" value="{!$Label.site.submit}" id="submit" />



public with sharing class CommunitiesSelfRegController {

public String firstName {get; set;}
public String lastName {get; set;}
public String email {get; set;}
public String CompanyName {get; set;}  
public String Department {get; set;} 
public String Division {get; set;} 
public String State {get; set;}
public String Phone {get; set;}
public String Country {get; set;}
public String Title {get; set;}
public String Client_ID_c {get; set;}
public String Enable_Notifications_c {get; set;}
public String Role_c {get; set;}
public String Agree_to_Terms_and_Conditions_c {get; set;} 
public String password {get; set {password = value == null ? value : value.trim(); } }
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }

public CommunitiesSelfRegController() {}

private boolean isValidPassword() {
    return password == confirmPassword;

public PageReference registerUser() {

       // it's okay if password is null - we'll send the user a random password in that case
    if (!isValidPassword()) {
        ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
        return null;

    String profileId = null; // To be filled in by customer.
    String roleEnum = null; // To be filled in by customer.
    String Division = Division;
    String accountId = ''; // To be filled in by customer.
    String nickname = firstName + ' - ' + email;
    String userName = email;
    String Country = Country;
    String State = State;
    String Phone = Phone;
    String Title = Title;
    String Client_ID_c = Client_ID_c;
    String Enable_Notifications_c = Enable_Notifications_c;
    String Role_c = Role_c;
    String Agree_to_Terms_and_Conditions_c = Agree_to_Terms_and_Conditions_c;

    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.Division = Division;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.Self_Registered__c = TRUE;
    u.CompanyName = CompanyName;
    u.Department  = Department;
    u.CommunityNickname = nickname;
    u.ProfileId = profileId;
    u.Country = Country;
    u.State = State;
    u.Phone = Phone;
    u.Title = Title;

    String userId = Site.createPortalUser(u, accountId, password);

    if (userId != null) { 
        if (password != null && password.length() > 1) {
            return Site.login(userName, password, ApexPages.currentPage().getParameters().get('startURL'));
        else {
            PageReference page = System.Page.CommunitiesSelfRegConfirm;
            return page;
    return null;


So, when I am using a Custom Field I get errors. When I remove the Custom Field and put in a standard field from the User, I have no issues. I've tried different variations of "__c" and "_c", but I am coming up short, does anyone know what my noobie mistake is for this? I have a feeling it has to do with my naming of the field...?

EDIT: Added the full code in (excluding the CSS styling)

  • For starters, custom fields are always suffixed with __c (2 underscores). I do notice you write it with 1 underscore in the VF and the controller. Are you sure that's not the problem? – Folkert Jun 23 '15 at 14:57
  • I had tried that and it wasn't working properly at the top of the controller in the public String section. It would give me an error. By moving it to 1 underscore it let me 'save' and now the issue is on creating the new User? – David Litton Jun 23 '15 at 15:03
  • Perhaps you could show us the complete code for your controller and VF page? In both, any custom fields should have a __c (2 underscores). If it let you save with only one, then it's likely there's an issue with the field name not matching the schema or the getters and setters. – crmprogdev Jun 23 '15 at 15:56
  • Yes, sharing your code would help. Are you extending a standard controller or using a custom controller? If you use a standard controller (alone or with extension) you can just refer to the custom field in the VF inputfield like value="{!user.Client_ID__c}". Using 2 underscores in a variable or property name like you do now will cause errors, as two underscores are reserved for custom fields. – Folkert Jun 23 '15 at 20:51
  • Just added more of the code. We are basing all of this off of the standard controller/vfp that Salesforce starts the community self registration with. – David Litton Jun 23 '15 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.