Skip to main content

Salesforce Validation Error: Value is not valid error

 When the Visualforce page is submitted, sometimes we can see the error "Error: Validation Error: Value is not valid"


This is because when the form is submitted to salesforce server, The picklist value that is being submitted, will be checked with the list of available values in the server at that time. If there is no matching entries, This error can be thrown.

If you are using picklist in the page, Make sure that

1. The list of available picklist values always include the picklist value that is selected.

2. If you are using the getter to populate the picklist values, The getter will be always called before form submission which could bring the different set of list values than the values that were available at the time picklist value selection. So instead of using getter, you can use constructor or action method to get the list of values.

3. If the picklist value contains multiple consequtive spaces (ex. Internal   User), When it is rendered as HTML, The html supresses any extra spaces and displays only one space. (Internal User).When this value is submitted, as there is no matching picklist values, you would get the error. The workaround is to remove any extra spaces in the picklist strings.

4. At last, Try to use the list instead of set for the picklist values. Since the set is unordered colllection, You might get the values in different order which can cause the issue too.