Skip to main content

Return to TX Community

Liaison

Adding Different Data Type Fields to Communities Contact Matching

Creating Text Fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following near the top of the class, adding the Variable Name (in bold):
public String department {get; set { department = value == null ? value : value.trim(); } }

Step 2: Add the new fields to the Update command

  1. Update the following line with additional fields that will save data to the Contact record (areas in bold are the new fields). Enter the API Name of the Contact field for the highlighted item:
update new Contact(Id=contactId, AccountId=accountId, Department = department);
  1. Save your changes.

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  update new Contact(Id = contactId, Department = department);

Step 3: Add the field to the Sign Up Page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code. Enter the Variable Name for the bolded items. The other items in bold are the Question labels:
<label class="targetx-input-label targetx-required">
    <apex:inputText styleClass="targetx-input-text" value="{!department}" label="Department" required="true"/>
    <span>Department</span>
</label>

Step 4: Add the new Fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Creating Date fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following near the top of the class, adding the Variable Name (in bold):
public Date birthdate {get; set;}

Step 2: Add the new fields to the Update command

  1. Update the following line with additional fields that will save data to the Contact record (areas in Bold is the API Name = Variable Name for the new fields):
update new Contact(Id=contactId, AccountId=accountId, Birthdate = birthdate);

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  

update new Contact(Id=contactId, Birthdate = birthdate);
  1. Save your changes.

Step 3: Add the field to the Sign Up page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code. Enter the Variable Name for the bolded value. The other items in bold are the Question labels:
<div class="targetx-input-label">
    <span style="font-size:14px">Birth Date :</span>
</div>
<label class="targetx-input-label targetx-required">
    <apex:input type="date" value="{!birthdate}" required="true" label="Birth Date"/> 
</label>
  1. Save your changes.

Step 4: Add the new fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Creating Decimal Fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following near the top of the class, adding the Variable Name (in bold):
public Decimal targetXSRMbAverageGPA {get; set;}

Step 2: Add the new fields to the Update command 

  1. Update the following line with additional fields that will save data to the Contact record (areas in bold  is the API Name = Variable Name for the new fields):
update new Contact(Id=contactId, AccountId=accountId, TargetX_SRMb__Average_GPA__c = targetXSRMbAverageGPA);

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  

update new Contact(Id=contactId, TargetX_SRMb__Average_GPA__c = targetXSRMbAverageGPA);
  1. Save your changes.

Step 3: Add the field to the Sign Up page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code. Enter the Variable Name for the highlighted item. The other items in red are the Question labels:
<label class="targetx-input-label targetx-required">
    <<apex:inputText styleClass="targetx-input-text" id="targetXSRMbAverageGPA" value="{!targetXSRMbAverageGPA}" label="Avg GPA" required="true"/>
    <span>Avg GPA</span>
</label>
  1. Save your changes.

Step 4: Add the new fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Creating Picklist Fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following near the top of the class:
public String athleticProspect {get; set { athleticProspect = value == null ? value : value.trim(); } }
  1. Add the code below under the set of codes from the top. The first item in bold must be unique if you are adding multiple picklist fields. The second item in red is the API Name of the Contact field you are adding:
public List<Selectoption> getPickListFieldOptions(){
        List<SelectOption> options = new List<SelectOption>(); 
        List<Schema.Picklistentry> fieldResult = Contact.Athletic_Prospect__c.getDescribe().getPicklistValues();
        options.add(new SelectOption('', 'Please select an option'));
        for(Schema.PicklistEntry f : fieldResult) {
            options.add(new SelectOption(f.getValue(), f.getLabel()));
        }
        return options;
    }

Example:
picklist field example

  1. Add the code below in the Script Tag (if not already added):
window.onload = function(){
        var elems = document.querySelectorAll ('[id$="Required"]');
         for (var i = 0; i < elems.length; i++){
              elems[i].required = true;
            console.log(elems[i]);
        }
    }
  1. Save your changes.

Step 2: Add the new fields to the Update command

  1. Update the following line with additional fields that will save data to the Contact record (areas in bold are the new fields). Enter the API Name of the Contact field for the highlighted item:
update new Contact(Id=contactId, AccountId=accountId, Athletic_Prospect__c = athleticProspect);

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  

update new Contact(Id=contactId, Athletic_Prospect__c = athleticProspect);
  1. Save your changes.

Step 3: Add the field to the Sign Up page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code:
<apex:pageBlockSectionItem >
      <label class="targetx-input-label targetx-required" style ="font-size:18px">
      <apex:outputLabel value="Are you an Athlete?" styleClass="targetx-input-label targetx-required" />
      <apex:selectList value="{!athleticProspect}" id="pickListRequired" size="1" styleClass="targetx-input-text" required="true" style="margin-top:-20px">
      <apex:selectOptions value="{!PickListFieldOptions}" />
      </apex:selectList>
      </label>
</apex:pageBlockSectionItem>

Notes:

  • Are you an Athlete? = Question Label
  • athleticProspect = Variable Name
  • pickList = This value must be unique if adding more than one picklist field, including multi-picklist fields.
  • PickListFieldOptions = Picklist Options Variable Name.  If adding multiple picklist fields, this value must be unique and match the same unique value in Step 1.4
  1. Save your changes.

Step 4: Add the new Fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Creating Multi-Picklist Fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following to the top of the class:
public String[] targetXSRMbIPEDSEthnicities {get; set;}
  1. Add the code below under the set of codes from the top. The first item in red must be unique if you are adding multiple picklist fields. The second item in red is the API Name of the Contact field you are adding:
public List<Selectoption> MutliPickListFieldOptions(){
        List<SelectOption> options = new List<SelectOption>(); 
        List<Schema.Picklistentry> fieldResult = Contact.TargetX_SRMb__IPEDS_Ethnicities__c.getDescribe().getPicklistValues();
            for(Schema.PicklistEntry f : fieldResult) {
            options.add(new SelectOption(f.getValue(), f.getLabel()));
        }
        return options;
    }
  1. Add the code below in the Script Tag (if not already added):
window.onload = function(){
        var elems = document.querySelectorAll ('[id$="Required"]');
         for (var i = 0; i < elems.length; i++){
              elems[i].required = true;
            console.log(elems[i]);
        }
    }
  1. Save your changes.

Step 2: Add the new fields to the Update command

  1. Update the following line with additional fields that will save data to the Contact record (areas in bold are the new fields):
update new Contact(Id=contactId, AccountId=accountId, TargetX_SRMb__IPEDS_Ethnicities__c = targetXSRMbIPEDSEthnicities.isEmpty() ? '' : string.join(targetXSRMbIPEDSEthnicities,';'));

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  

update new Contact(Id=contactId, TargetX_SRMb__IPEDS_Ethnicities__c = targetXSRMbIPEDSEthnicities.isEmpty() ? '' : string.join(targetXSRMbIPEDSEthnicities,';'));
  1. Save your changes.

Step 3: Add the field to the Sign Up page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code:
<apex:pageBlockSectionItem >
      <label class="targetx-input-label targetx-required" style ="font-size:18px">
      <apex:outputLabel value="What is your Ethnicity?" styleClass="targetx-input-label targetx-required"/>
      <apex:selectList value="{!targetXSRMbIPEDSEthnicities}" multiselect="true" id="multipickListRequired" size="6" styleClass="targetx-input-text multipicklist-css" required="true" >
       <apex:selectOptions value="{!MultiPickListFieldOptions}" />
       </apex:selectList>
       </label>
</apex:pageBlockSectionItem>

Notes:

  • What is your Ethnicity? = Question Label
  • targetXSRMbIPEDSEthnicities = Variable Name
  • multipickList = This value must be unique if adding more than one picklist field, including multi-picklist fields.
  • = This number can be adjusted to increase or decrease the size of the multi-picklist field on the student facing side.
  • Multipicklist-css = CSS Styling reference name.  This naming convention can be customized to your needs.
  • MultiPickListFieldOptions = This value must be unique if adding more than one picklist field, including multi-picklist fields.
  1. Add the following code in the Style tag near the bottom of the page. The item in bold can be customized, but must also be updated in Step 3.3:
.multipicklist-css {
border-top: 1px solid #d3d6d9 !important;
border-bottom: 1px solid #d3d6d9 !important;
margin-top: -40px;
overflow: auto;
}


option {
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}
  1. Save your changes.

Step 4: Add the new Fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Creating Radio Button Fields

Step 1: Add variables with getter and setter and trim

  1. Navigate to Setup and search for Apex Classes.
  2. Select TX_CommunitiesSelfRegController and click Edit.
  3. Add the following near the top of the class:
public String targetXSRMbGender {get; set { targetXSRMbGender = value == null ? value : value.trim(); } }
  1. Add the below code under the set of codes from the top. The first option in red is the Options Variable Name. This value must be unique if adding more than one picklist field, including multi-picklist fields:
public List<Selectoption> getRadioFieldOptions(){
        List<SelectOption> options = new List<SelectOption>(); 
        List<Schema.Picklistentry> fieldResult = Contact.TargetX_SRMb__Gender__c.getDescribe().getPicklistValues();
        for(Schema.PicklistEntry f : fieldResult) {
            options.add(new SelectOption(f.getValue(), f.getLabel()));
        }
        return options;
    }
  1. Add the below code in the script tag. The first item in bold is the Variable Name:
function settargetXSRMbGender(val, hidden) {
        document.getElementById(hidden).value = val;
    }
  1. Save your changes.

Step 2: Add the new fields to the Update command

  1. Update the following line with additional fields that will save data to the Contact record (areas in bold are the new fields):
update new Contact(Id=contactId, AccountId=accountId, TargetX_SRMb__Gender__c = targetXSRMbGender);

Note:AccountId=accountIdshould be removed from the update new Contact method if your institution is not using the school picker and/or not using EDA Administrative Accounts. Instead, the code would be similar to the following:  

update new Contact(Id=contactId, TargetX_SRMb__Gender__c = targetXSRMbGender);
  1. Save your changes.

Step 3: Add the field to the Sign Up page

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select TX_CommunitiesSelfReg and click Edit.
  3. Add the following after the Email Address code:
<apex:pageBlockSectionItem >
 <apex:inputHidden value="{!targetXSRMbGender}" id="hidValId" />
        <div class="targetx-input-label targetx-required" style ="font-size:18px; padding-bottom: 15px">
        <span>What is your Gender?</span> 
        </div>
        <apex:repeat value="{!RadioFieldOptions}" var="radioField" >
        <input type="radio" name="inputRadio" onclick="settargetXSRMbGender(value,'{!$component.hidValId}');" required="true" value="{!radioField.value}" style="margin-right:10px"/>
        <option class="radioinput-label">{!radioField.label}</option> <br/> <br/>                          
        </apex:repeat>  
        </apex:pageBlockSectionItem><br/>

Notes:

  • targetXSRMbGender = Variable Name
  • hidValId = Must be unique if adding multiple radio button fields.
  • What is your Gender? = Question Label
  • RadioFieldOptions = Options variable name.  Must match name in step 1.4.
  • radioField = Must be unique if adding multiple radio button fields.
  • inputRadio = Must be unique if adding multiple radio button fields.
  • targetXSRMbGender = Variable Name
  • hidValId = ID from apex:inputHidden tag
  • radioField = var value from apex:repeat tag
  1. Add the following code in the Style tag near the bottom of the page:
input[type=radio] {
    transform: scale(1.5);
}
    
.radioinput-label {
    display: contents;
    font-size:18px;
}
  1. Save your changes.

Step 4: Add the new Fields to Contact Matching (optional)

Refer to How to add additional fields to Contact matching in the article Expanding Communities Contact Matching.

Note: Any fields added to the sign up page will require field level permissions of Read/Edit to be added for the Online Application Guest Site User profile.

 

 

  • Was this article helpful?