1

I am facing some validation error on vf page.

j_id0:frm:pageBlock:artist: Validation Error: Value is not valid
j_id0:frm:pageBlock:lotno: Validation Error: Value is not valid
j_id0:frm:pageBlock:exhibition: Validation Error: Value is not valid
j_id0:frm:pageBlock:ItemNo: Validation Error: Value is not valid

Here some code related to this error-

<apex:form id="frm">

<b><apex:outputLabel value="Search:" />&nbsp;</b>
<apex:inputText value="{!searchText}" />
<apex:commandButton action="{!searchRecords}" status="status" rerender="artist,lotno,exhibition,frm" value="Search">
    <apex:param name="searchClick" value="true" assignTo="{!searchClick}"></apex:param>
</apex:commandButton>&nbsp;&nbsp;&nbsp;&nbsp;
<!--apex:commandButton action="{!reset}" status="status" rerender="artist,lotno,exhibition,frm" value="Reset"/-->
<apex:commandButton value="Reset" onclick="javascript:openResetPage();return false;" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b><apex:outputLabel value="Search Filters:" /></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>Artist: </b><apex:selectList value="{!artistSelected}" id="artist" size="1">
    <apex:selectOptions value="{!artistOptions}" />
    <apex:actionSupport event="onchange" action="{!subFilter}"  rerender="artist,lotno,exhibition,frm" status="status">
       <apex:param name="typeString" value="artist" />
       <apex:param name="subfilterClick" value="true" assignTo="{!subfilterClick}"/>
    </apex:actionSupport>
</apex:selectList>&nbsp;&nbsp;
<b>Lot No.</b> <apex:selectList value="{!lotnoSelected}" id="lotno" size="1"> 
    <apex:selectOptions value="{!lotnoOptions}" />
    <apex:actionSupport event="onchange" action="{!subFilter}"  rerender="artist,lotno,exhibition,frm" status="status">
       <apex:param name="typeString" value="lotno" />
       <apex:param name="subfilterClick" value="true" assignTo="{!subfilterClick}"/>
    </apex:actionSupport>
</apex:selectList>&nbsp;&nbsp;&nbsp;
<b>Exhibition: </b><apex:selectList value="{!exhibitionSelected}" id="exhibition" size="1">
    <apex:selectOptions value="{!exhibitionOptions}" />
    <apex:actionSupport event="onchange" action="{!subFilter}"  rerender="artist,lotno,exhibition,frm" status="status">
       <apex:param name="typeString" value="exhb" />
       <apex:param name="subfilterClick" value="true" assignTo="{!subfilterClick}"/>
    </apex:actionSupport>
</apex:selectList>&nbsp;&nbsp;&nbsp;
<b>Item No: </b><apex:selectList value="{!itemNoSelected}" id="ItemNo" size="1">
    <apex:selectOptions value="{!itemNoOptions}" />
    <apex:actionSupport event="onchange" action="{!subFilter}"  rerender="artist,lotno,exhibition,frm" status="status">
       <apex:param name="typeString" value="itemNo" />
       <apex:param name="subfilterClick" value="true" assignTo="{!subfilterClick}"/>
    </apex:actionSupport>
</apex:selectList>

Here some controller code-

public class Controller{
    public transient  list<SelectOption> artistOptions{set;get;}
    public transient  list<SelectOption> lotnoOptions{set;get;}
    public transient  list<SelectOption> exhibitionOptions{set;get;}
    public transient  list<SelectOption> itemNoOptions{set;get;}

    public Controller(){
        artistOptions = new list<SelectOption>();
        artistOptions.add(new SelectOption('--none--','--none--'));
        lotnoOptions = new list<SelectOption>();
        lotnoOptions.add(new SelectOption('--none--','--none--'));
        exhibitionOptions = new list<SelectOption>();
        exhibitionOptions.add(new SelectOption('--none--','--none--'));
        itemNoOptions = new list<SelectOption>();
        itemNoOptions.add(new SelectOption('--none--','--none--'));
    }

    private void BindData(Integer newPageIndex, String tmyExp){
        system.debug('--------In BD-----------');
        String queryStr = '';
        queryStr= 'SELECT (Select Id, ParentId, Name, LastModifiedDate From Attachments where ContentType = \'application/pdf\' OR  ContentType = \'application/doc\' OR ContentType = \'application/docx\'  order by LastModifiedDate desc limit 1),';
        queryStr+= ' Name, Id, Item_No__c, Lot_No__c, artApp__Exhibition__r.Name, ';
        queryStr+= 'artApp__Primary_Image_Id__c, ';
        queryStr+= ' Barcode_ID__c, Dimensions__c, ';
        queryStr+= 'RecordType.Name, artApp__Artist__r.Name, artApp__Collector__r.Id,';
        queryStr+= 'Internal_Location__r.Name, Packed_Dimensions__c, Packing_Method__c FROM artApp__Artwork__c';
        queryStr+= '   Where artApp__Collector__r.artApp__Email__c= \'' + currentEmail + '\' AND (NOT(Internal_Location__r.Name LIKE \'%release%\' OR Internal_Location__r.Name LIKE \'%held by%\' OR Internal_Location__r.Name LIKE \'%deliver%\' OR Internal_Location__r.Name LIKE \'%not ship%\' OR Internal_Location__r.Name LIKE \'%pending%\' OR Internal_Location__r.Name LIKE \'%fp to cc%\' OR Internal_Location__r.Name LIKE \'%cc to fp%\' OR Internal_Location__r.Name LIKE \'%enroute%\' OR Internal_Location__r.Name = \'\' OR Internal_Location__r.Name LIKE \'%tbc%\' OR Internal_Location__r.Name LIKE \'%old record%\')) ORDER BY '+ tmyExp;
        //queryStr+= '   Where (NOT(Internal_Location__r.Name LIKE \'%release%\' OR Internal_Location__r.Name LIKE \'%deliver%\' OR Internal_Location__r.Name LIKE \'%not ship%\' OR Internal_Location__r.Name LIKE \'%pending%\' OR Internal_Location__r.Name LIKE \'%fp to cc%\' OR Internal_Location__r.Name LIKE \'%cc to fp%\' OR Internal_Location__r.Name LIKE \'%enroute%\' OR Internal_Location__r.Name = \'\' OR Internal_Location__r.Name LIKE \'%tbc%\' OR Internal_Location__r.Name LIKE \'%old record%\')) ORDER BY '+ tmyExp;

        //Used to populate the filter lists

        try {

            system.debug('--------BD---4--------');
            pageAccounts = new List<artApp__Artwork__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;


            artistOptions = new list<SelectOption>();
            lotnoOptions = new list<SelectOption>();
            exhibitionOptions = new list<SelectOption>();
            itemNoOptions = new list<SelectOption>();
            artWorkWrapperListOriginal =  new list<artWorkWrapper>();
            Set<String> set1 = new Set<String>();
            Set<String> set2 = new Set<String>();
            Set<String> set3 = new Set<String>();
            Set<String> set4 = new Set<String>();
            system.debug('--------BD---8--------');
            transient integer sizeSet1 = 1;
            transient integer sizeSet2 = 1;
            transient integer sizeSet3 = 1;
            transient integer sizeSet4 = 1;
            for(artApp__Artwork__c searcrec : tempData){
                artWorkWrapper aww =  new artWorkWrapper();
                aww.apArt = searcrec;
                if(searcrec.Attachments != null && searcrec.Attachments.size() > 0) {
                    for(Attachment aa: searcrec.Attachments) {
                        aww.attachmentrec = aa.Id;
                    }
                }
                //artWorkWrapperListOriginal.add(aww);
                 if(searcrec.artApp__Artist__r.Name != null){
                   if(sizeSet1<=1000){
                     set1.add(searcrec.artApp__Artist__r.Name);
                     sizeSet1++;
                   }
                }
                if(searcrec.Lot_No__c != null){
                  if(sizeSet2<1000){
                        set2.add(searcrec.Lot_No__c);
                        sizeSet2++;
                  }
                }
                if(searcrec.artApp__Exhibition__r.Name != null){
                  if(sizeSet3<1000){
                        set3.add(searcrec.artApp__Exhibition__r.Name);
                        sizeSet3++;
                  }
                }
                if(searcrec.Item_No__c != null){
                    if(sizeSet4<1000){
                        set4.add(searcrec.Item_No__c);
                        sizeSet4++;
                    }
                }
            }
            List<String> tempList = null;
            if(set1 != null && set1.size() > 0) {
                artistOptions.add(new SelectOption('All','All'));
                tempList = new List<String>();
                tempList.addAll(set1);
                tempList.sort();
                for(String s1: tempList) {
                    artistOptions.add(new SelectOption(s1,s1));
                }
            }

            if(set2 != null && set2.size() > 0) {
                lotnoOptions.add(new SelectOption('All','All'));
                tempList = new List<String>();
                tempList.addAll(set2);
                tempList.sort();
                for(String s2: tempList) {
                    lotnoOptions.add(new SelectOption(s2,s2));
                }
            }
            if(set3 != null && set3.size() > 0) {
                exhibitionOptions.add(new SelectOption('All','All'));
                tempList = new List<String>();
                tempList.addAll(set3);
                tempList.sort();
                for(String s3: tempList) {
                    exhibitionOptions.add(new SelectOption(s3,s3));
                }
            }

            if(set4 != null && set4.size() > 0) {
                itemNoOptions.add(new SelectOption('All','All'));
                tempList = new List<String>();
                tempList.addAll(set4);
                tempList.sort();

                for(String s4: tempList) {
                    itemNoOptions.add(new SelectOption(s4,s4));
                }
            }

            //this.attachments();
            //pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
            }
        } catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
        system.debug('--------BD---11--------');
    }
}
  • 1
    All relate to apex:selectList and seems like the list you are binding have invalid data. Can you please post the controller codes too for populating selectOptions values? – highfive Aug 14 '16 at 15:06
  • @highfive I added some code from controller. Actually Code too large so I copied Selectoption part which is related to Error. – user24524 Aug 14 '16 at 16:48
3

Normally this error is thrown when a picklist value is being submitted to the server and there's no matching entry for the given picklist value in the server at the submitting time.

Two possibilities that I can think of:

  1. Since you are using sets, which are unordered collections, the order might have been changed at the time of submitting data to the server which can be raised the validation error.

  2. In your strings used as SelectOptions keys, there can be strings which include multiple consecutive spaces which can be raised the validation error.

Check for these possibilities. The reason for second possibility is because even in your list it's having multiple spaced string, when it renders it binds with single space. When the data submitted back, it will cross check with the list again and values do not get matched.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.