Custom display column for lookup

LabKey Support Forum (Inactive)
Custom display column for lookup Andy Straw  2014-05-19 11:06
Status: Closed
 
I had a similar problem, and solved it as follows - not sure this will work for you:

I wrote a query that builds the combined display field. For your list, the query would be something like:

SELECT
   name || ' (' || number || ')' AS title,
   name,
   number,
   key
FROM
   Antibody

If you need to use this as the target of a lookup from some other List, Dataset, or Assay, you'll need to add XML metadata to the query to define a key field - otherwise, the query won't show up in the list of tables in the "lookup" drop-down when you are defining the type of the source field in that List, Dataset, or Assay. Something like this:

<tables xmlns="http://labkey.org/data/xml">
 <table tableName="QueryNameGoesHere" tableDbType="NOT_IN_DB">
   <columns>
     <column columnName="Key">
       <isKeyField>true</isKeyField>
     </column>
   </columns>
 </table>
</tables>

To get the "title" field to be the display column of the query (so it's used in the "lookup" dropdown), I made it the first column in the SELECT statement. There's probably a way to specify that in XML metadata instead.

Hope this helps.

Andy Straw
University of Rochester