Toggle menu

Form Variable - Lookup

This field creates a server-side variable of key-value pairs that can be looked up by form functions. Display values can be looked up using the .getOptionVariableDisplayValue function.

Properties

LabelDescriptionType Name
Variable NameThe name of the variable. If no name is specified the field name will be usedVARNAME
Lookup OptionsThe key-value pairs that will be stored in the variable. Use the popup editor to set the Value and Display values for each option. These values may be hard-coded (fixed) or dynamically loaded from a datasource.

Hard-coded values can be entered using the grid provided on the "Fixed" tab of the popup editor. Alternatively, they can be supplied as comma-separated values (value,display) via the "Fixed (CSV)" tab, with each row representing a single option.

Dynamically loaded values are set via the "Datasource" tab of the popup editor. The datasource must already be defined - see Using External Datasources. Typically, specifying the table, value, display and order by column names in the boxes provided will generate a suitable query. A custom query can be entered by expanding the "Advanced" section; it will use any names set in the above boxes to generate a starting query. This custom query should set the value into a "DataValue" column, and the display value into a "DataDisplay" column. For example:

SELECT ValueColName as DataValue, DisplayColName as DataDisplay FROM TableName ORDER BY OrderByColName ASC
OPTIONS
Lookup Options FunctionA server-side JavaScript function that can manipulate or generate the options at the time the field is generated. This function will be executed server-side only. It is supplied the current Lookup Options as the optionData parameter.

For example the following will replace any fixed or database query options with 10 numbered options:

function (helper, optionData) {    
    optionData = [];    
    for (var i=1; i <= 10; i++) {
        optionData.push([i.toString(), "Option number " + i]);
    }    
    return optionData;
}
OPTIONSFUNC
DocumentationAdd documentation to your field to help explain any complex functionality to future users. You might include information on what the field does and how it relates to other fields on the form. Notes added here are only ever visible in the Forms Designer, they can be searched for, viewed and downloaded from the action panel. See Common Field Properties for an exampleDOCUMENTATION

Example

Setting the following fixed options:

Fixed Options
 

Creates a form variable with the following value:

[
    ["1", "one", ""],
    ["2", "two", ""],
    ["3", "three", ""]
]

Last modified on August 18, 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon