Validation Error: value is not valid error in Salesforce

Validation Error: value is not valid error in Salesforce

This error may be due to assigning Set data type variable to <apex:selectOptions/>.

The workaround for this is, assign the Set data type values to List data type variable and assign it to the <apex:selectOptions/>.

Sample Controller:

Set<SelectOption> optionsSet = new Set<SelectOption>();
List<SelectOption> optionsList = new List<SelectOption>();

for(){
        optionsSet.add(…….., ‘………..’);
}
optionsList.addAll(optionsSet);

Sample VF Page:

<apex:SelectList>
        <apex:selectOptions values=”{!optionsList}”/>
</apex:SelectList>

Cheers!!!


Happy Coding!!!

Leave a Reply