+ Start a Discussion

Dynamic/Conditional Required fields

So based on the discussion board, it seems like you can make conditional required fields through validation rules. However, is there a way to let the customer know which conditional fields are required based on their input? (i.e. display a red line at a conditional field if it is required, and no red line if it is not required)? 


Or does anyone have any tips/advice on how best to display/let the customer know which conditional fields are required based on their input? 


Thanks in advance! 


U can make the field required as following.


1.Through Validation rules.

2.select the checkbox as Required when they are created the fields itself.

3.Using vf page make required="true".




Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi Rytom,


In Salesforce other than validation rules, there are many options avialble for your question.


  1. While creating a field for an object there is an option called Required checkbox vailable. If you make it enable you can show a red color mark in your field while creating a record.
  2. Also, you can enable required option through Page Layout. Double Click on the field, so that you can make the field either Required or Readonly.
  3. Or you can make this enable by creating a VF page and make the field property as follows,

          <apex:inputfield value="{!sobject.field__c}" required = "True"/>



Hope so this helps you...!

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.




Sorry I should have been more clear. Here is the scenario: 


I have a custom object with a checkbox that is called "Use Default Address" and another field where the user can enter in their address called "Address". 


If the user selects the checkbox "Use Default Address", they should not fill out the "Address" field. If the user fills out the "Address" field, they should not select the checkbox. I've set up 2 validation rules that makes sure that both these fields cannot be selected at the same time. 


However, I want to somehow display to the user that these two fields are required (i.e. have some type of visual, like the red line for fields when they are made required to have values) "Use Default Address" checkbox and "Address" field. However, setting both these two fields as required (so that both will have a redline marking them as required for the customer) will then cause conflict with my two validation rules that checks that only either/or of these two fields can be filled out. 


To summarize my question, is there someway to make both these field "required" so that they will have the red line next to them, yet somehow have it so that if one of these fields are filled out the other doesn't have to be? 


Thanks in advance! 




I've created a test object called "Forum_Object__c" with two fields, "Address__c" and "Use_Default_Address__c".  The following VF page shows how to make the "Address" field required only if "Use Default Address" is not checked.


<apex:page standardController="Forum_Object__c" extensions="ForumExtension">
<apex:form >
    <apex:pageBlock title="Test">
        <apex:actionRegion >
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{!Forum_Object__c.Use_Default_Address__c}">
                <apex:actionSupport event="onchange" rerender="theSection"/>
        <apex:pageBlockSection columns="1" id="theSection">
            <apex:inputField value="{!Forum_Object__c.Address__c}" required="{!requireAddress}"/>


The controller extension, "ForumExtension", is:


public with sharing class ForumExtension
    private Forum_Object__c theRecord;

    public Boolean requireAddress { get { return !theRecord.Use_Default_Address__c; } }

    public ForumExtension( ApexPages.StandardController theController )
        theRecord = (Forum_Object__c) theController.getRecord();


If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!


-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator


Thanks, Glyn. Helped for my situation (slightly different).

Adapted this for my case http://patlatus.wordpress.com/2014/09/22/salesforce-make-dependent-field-required-for-specific-values-of-primary-field/