What is the way to enforce that a user can only insert unique values for a certain field in a custom list? [EOM] | Jon (LabKey DevOps) | 2015-10-28 13:07 |
Status: Closed | ||
Hi Leo, If you need to have one column with a preset series of values, you could do the following: 1. Create another list 1a. Rename the Primary Key to what you'd like the field to be called 1b. Select the Primary Key Type as String. 1c. Click Create List 2. Add the preset values you want in that list under that one single column 3. Create another list and add a lookup to that first list, enable the validation lookup and make it required. The new list will lookup the other one and only give the end-user a specific preset number of options to use for the one column based on the other list. With regard to trying to have a behavior similar to the primary key restriction on another column, this functionality is unfortunately not available in lists as-is from what I can see. However, you could create a Trigger Script module to where it will only allow you to insert new rows provided the value isn't being used. This would only work on individually inserted records though and not when you import data via a copy/paste of TSV data. https://www.labkey.org/wiki/home/Documentation/page.view?name=serverSideValidation The trigger script would have to use the beforeInsert(row, errors) function to trigger just before the insert was attempted. Then, it would have to read the row.FIELD you were inputting and perform an IF/ELSE statement where IF the value of the field you're inputting equals to any of the existing values in that same field, generate an error; else insert the new record. Regards, Jon |
||