Query as lookup Andy Straw  2014-03-13 05:03
Status: Closed
 
When defining a field in a List, I can make the type of that field a lookup to another table. If the other table is another List, this is easy: I just pick schema=lists, and then select the other list from the drop-down. Is it possible to get a query - rather than a list - to show up this drop-down? I thought it might just require that I add table metadata to the query to identify the primary key, but when I did that, it didn't seem to have any effect; perhaps my xml is incorrect:

<tables xmlns="http://labkey.org/data/xml">
  <table tableName="Lookups" tableDbType="NOT_IN_DB">
    <pkColumnName>ShortName</pkColumnName>
  </table>
</tables>

Is this possible, and if so, how is it done? Thanks.

Andy Straw
University of Rochester
 
 
jeckels responded:  2014-03-13 08:47
Hi Andy,

Yes, this is possible. Try using the column-level variant instead:

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

Thanks,
Josh
 
Andy Straw responded:  2014-03-13 10:50
That worked. Thanks very much.

Andy