Lookup lists

A lookup list defines the allowed values for a field. A lookup list enumerates all valid items. A simple example of a lookup list is a list of countries, years, genders, etc.

Lookup lists help to restrict the set of possible entries for a field when only certain values should be allowed, as well as providing an easy way to input common values and avoid typing errors. Here is an example:

 

Local lookup lists

When a lookup list is only used for one field, the best way to define the list is as a local lookup list. Follow these steps:

  • In the class screen, at the field tab, click the "go to details"-button at the right side of the field of choice.
  • Choose the tab 'Lookup items'.
  • Click the button 'Add lookup list item'.
  • Each item should have at least a key. Suppose we have a "person" class and we want the field to contain the gender of a person. The data type can be "text" in this case, and the two keys that could be added in this case would be 'm', 'f' and 'o'. You can also define user-friendly labels like 'male', 'female' and 'other'. This is the text that is shown to the user in the application.

Global lookup list

When a lookup list is used for more than one field, creating a global lookup list might be a more efficient option. Follow these steps:

  • Select 'lookup lists' from the studio left menu;
  • Click the 'add global lookup list' button at the top to add a new lookup list;
  • Enter a name;
  • Choose a data type. 
  • Add lookup list items;
  • Fill in the keys, same as for a local lookup list (see section above).

After you have defined a global lookup list, you can use it on one or more fields.To do this, go to the details of the field and select the global lookup list as the datatype. We created a global lookup list called Size with the items S,M,L,XL and XXL(see example below).

 

  

Tip: Always start by creating a local lookup list. With the button ‘Convert to global lookup list’ it is easy to convert the local lookup list to a global lookup list.

Foreign class

When the field is a foreign key field, a lookup list will be created dynamically from the records in the foreign class. The keys in the lookup list items are created from the key of the foreign records. The labels in the lookup list items are created from the labels of the foreign records.

Lookup helpers

If the lookup can not be created from a static list or a foreign class, you can use a helper. See Lookup helpers.