Lookup subset Olivier  2015-03-30 06:37
Status: Closed
 
Hi,

I want to select a subset of rows from a list as lookup by filtering a specific value in a different field, i.e.

lookup list "access":

key,name,level
1,test1,100
2,test2,100
3,test3,100
4,test4,110
5,test5,110
6,test6,120

I want to display only those entries in the lookup field, where ("access".level = 100). Can I feed a SQL query as lookup or how do I filter a subset from a list?

thanks,
Olivier
 
 
Jon (LabKey DevOps) responded:  2015-03-30 15:55
Hi Olivier,

Yes, you can create a custom SQL query to do this, specifically applying a WHERE clause in your SQL statement and then you would use that query as the lookup target. You will also have to set the XML metadata to mark the primary key from the underlying table as a key field for this to work.

Take a look at this previous message board post from another user that has an example of the XML metadata and how to modify it for guidance.

https://www.labkey.org/announcements/home/Server/Forum/thread.view?entityId=49c0dcf1-8ccc-1031-abc2-6432661daa52&_docid=thread%3A49c0dcf1-8ccc-1031-abc2-6432661daa52

Let us know if you have any further questions.

Regards,

Jon