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
Dippan PatelDippan Patel 

Dependent Picklist is required but Picklist doesn't have any value

Hi All, 

How do I save the dependent picklist with no value even though it is required using Apex. 

Below is my visualforce page and controller code:
<apex:pageBlockSection title="Content Section" columns="1">

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

     <apex:inputField id="Street__c" label="Street " value="{!Street__c}"/>
     <apex:inputField id="City__c" label="City " value="{!City__c}"/>
      <apex:inputField id="State__c" label="State " value="{!State__c}"/> // dependent field
      <apex:inputField id="Country__c" label="Country " value="{!Country__c}"/> //controlling field

public class Test{

public Test(ApexPages.StandardController sc)
        obj = (TestAccount__c) sc.getRecord();

public ApexPages.PageReference SaveRecord()
            insert obj;
            PageReference pr = new PageReference('/' +;
            return pr;
        catch (Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());
            return null;

oth Country__c and State__c fields are required fields in field definition. The above code gives error "Required fields missing : [State]"  incase of countries with no states values. 
SwethaSwetha (Salesforce Developers) 
HI Dippan,
The issue you are facing seems related to know issue:

Can you check if this behaviour is specific to lightning experience or happens in the classic too?

If this information helps, please mark the answer as best.Thank you
Dippan PatelDippan Patel
Hi Swetha, 

Thank you. This happens for me in classic as well for the above code. Is there any workaround for this?