SPQuery on FilteredLookupField

Jul 18, 2011 at 2:57 PM


I've installed the FilteredLookupField field on my SP solution.. it works perfectly, i can filter the data that is displayed just fine, but i'm having a hard time using CAML to look for data on the field.

I have a list of employees with all their information and a Active field, which is a yes/no checkbox. I have a Image library called Pictures, where i want to save some pictures of the company.

In this image library, i have a Filtered Lookup Field, where i can choose the employees that appear on the picture, the lookup is filtered to show only the employees that are marked as Active on my employee list. it works fine. Then i have a custom page where i have a lookup field to choose a employee and the page will show all the pictures of that employee i chose.. the problem is that when i apply a CAML query to filter the Image Library, i get a error saying "One of more field types are not installed properly".

Can anyone tell me what i'm doing wrong?? My code is:

SPList employeeList = web.Lists["Employees"];
SPQuery queryEmployee = new SPQuery();
queryEmployee.Query = "<Where><Eq><FieldRef Name='Employee' LookupId='True' /><Value Type='Lookup'>" + employeeID + "</Value></Eq></Where>";
SPListItemCollection result = employeeList.GetItems(queryEmployee);

Thank you.

Aug 9, 2011 at 1:52 PM

Try to use LookupId='TRUE'

Oct 18, 2012 at 4:54 PM

Peppe, this does not work.

I have tried with both SPQuery and SPSiteData query with the same results.

Query will work for regular lookup fields on the same item but not for the filtered lookup fields.

I am not sure of the underlying cause -- perhaps some property is needed to ensure that the field is searchable?