March 26, 2014

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!!!

4 comments:

  1. The issue seems to be with something else. I am using the list, but its not helping at al.

    ReplyDelete
  2. Hi, thanks for the post it helped me

    ReplyDelete
  3. Hi, Thank you for the post it solved my day!

    ReplyDelete
  4. Hi, Thank you for the post it solved my day!

    ReplyDelete