name expression for lists

General Server Forum (Inactive)
name expression for lists camillesultana  2017-10-09 18:27
Status: Closed
 
Operating system: Windows 7
Browser: Chrome
Labkey: 17.20

I am very new to LabKey and not familiar with coding in xml or SQL to please bear with me.

I note that when creating a new list you have the option to create a primary key type that is either "auto-increment integer", "integer", or "text (String)". If the primary key is "integer" or "text(String)" then a column from the tsv (named "key" or something else) should populate the primary key information. However, I would really like to create a key for some of my lists with a "name expression" the same way unique ids can be created for sample sets. In particular this would be helpful in automatically generating succinct "storage location ids" that still impart some meaning to the users. For example if I have a list called "Storage Locations" with a variety of fields ("Lab", "StorageType", "Unit", "ShelfNumber"), is it possible to have labkey generate a name/primary key like ${Lab}_{StorageType}_{randomId} the way this is done for a sample set?
 
 
Jon (LabKey DevOps) responded:  2017-10-10 22:52
Hi Camille,

Unfortunately this isn't possible with lists. Lists are very simple tables and the Primary Key configuration is very ordinary, which is why the only options are to manually provide an integer or text value for the Primary Key or to have the system do an auto-increment for the integer.

Depending on your level of coding experience, it is possible for you to create your own interface to insert your records and to have it create your own key based on other values and have it concatenate it into the Primary Key field for your list.

Regards,

Jon