Database lookup

Created: - Updated:

This article covers the following topics:

Introduction to database lookup

Using database lookup, your survey can search for a user-defined field in a database that is hosted on the dashboard.  This field, called the key, could be the respondent's answer to a survey question, a scanned barcode, a sample field, or more.

Lumi Say supports both online and offline databases; offline databases are stored on the server but downloaded by the app with the survey content, while online databases remain on the server and require an internet connection to be accessed.  Online databases can be queried using remote lookup, while offline databases can be accessed using local lookup.

To upload a database to your survey:

  1. On the create page, select upload db.
  2. Click choose file, and find your database csv.
  3. If using local lookup, check the box next to offline database.
  4. Click import.

Databases must be in csv format and include the lookup fields in one column with id as the header.

Using remote lookup

Remote lookup can be used as actions in conditions.  To do so, use the following xml function:

barcode_lookup(db_name,key,var1,var2,...)

Parameter Description
db_name The file name of the uploaded database.  Do not include the .csv extension in this parameter.
key This is the field to be searched in the database.  This can be a question answer, survey variable, sample field, etc...
var The column header of the value to be returned by the lookup.  Multiple returns can be specified for each lookup key, separated by commas.  These return variables will automatically be created as survey variables with the same name as the column header.

In addition to creating survey variables with the returns of the lookup, this function will also create variables in the format r_var that return 0 if the lookup is unsuccessful, 1 if the lookup is successful, 2 if the device is offline, and 3 if the request times out.

Using local lookup

Local lookup can be used as actions in conditions.  To do so, use the following xml function:

local_lookup(db_name,key,var1,var2,...)

Parameter Description
db_name The file name of the uploaded database.  Do not include the .csv extension in this parameter.
key This is the field to be searched in the database.  This can be a question answer, survey variable, sample field, etc...
var The column header of the value to be returned by the lookup.  Multiple returns can be specified for each lookup key, separated by commas.  These return variables will automatically be created as survey variables with the same name as the column header.

In addition to creating survey variables with the returns of the lookup, this function will also create variables in the format r_var that return 0 if the lookup is unsuccessful, and 1 if the lookup is successful.