[SalesForce] Compile Error: Invalid bind expression type of List for column of type String

I have a req. to map The URL that is stored in the field which holds the url of the image in the documents. In VF page I reference the field that will hold the url from the documents.
So I created a Map
Controller :

public List<List<String>> IORefFormatedDescriptions {get;set;}
IORefFormatedDescriptions = new List<List<String>>();
    Map<String,String> urlMap = new  Map<String,String>();

        NewsXtendIORef__c[] campEles = [Select id, Name, Campaign_Element__c, Details__c, Quantity__c, Display_Order__c, URL__c FROM NewsXtendIORef__c WHERE Campaign_Element__c In: IORefFormatedDescriptions];

        for(NewsXtendIORef__c eleId : campEles){
            urlMap.put(eleId,'');
            if(eleId.URL__c != null){
                urlMap.put(eleId, eleId.URL__c);
            }
        }

VF page :

<apex:variable var="i" value="{!0}" />
                <apex:repeat value="{!IORefFormatedDescriptions}" var="row">
                    <tr style="font-size:14px;background-color:#B0C4DE;">
                        <apex:repeat value="{!row}" var="column">
                            <td>{!column}
                            <apex:variable var="i" value="{!i+1}"/>

                            <apex:outputPanel rendered="{!IF((mod(i,2)) == 0,false,true)}" style="text-align:center;" ><br></br>
                             <img src="{!urlMap[column]}" style="width:10px; height:20px; align:middle;" />
                            </apex:outputPanel>
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>

But I am getting the error because IORefFormatedDescriptions is List<List<String>>. How Can I iterate over this?

Best Answer

If you want to query where your field matches any of the String values in your List<List<String>>, you need to flatten your structure. Something like:

List<String> values = new List<String>();
for (List<String> subList : IORefFormatedDescriptions) values.addAll(subList);
List<MyObject__c> records = [SELECT Fields__c FROM MyOjbect__c WHERE Field IN :values];
Related Topic