showPicklistModal()
The showPicklistModal() function (client-side) prompts users to select options from popup tables or popup lists (formerly known as picklists and picklist dropboxes) without requiring them to click a button.
This function doesn't work with qTable popup lists (formerly known as qTable picklist dropboxes).
Syntax
Use this syntax for the showPicklistModal() function:
showPicklistModal('QUESTION_CODE', 'ANSWER_CODE').done(callback);
The callback function is optional.
Return Value
The showPicklistModal() function returns a promise that resolves to an object. The returned object shows whether users selected any options (true or false) and includes the selected values, if any. If users select options in the popup table or popup list, the returned object has the following structure:
{selected: true, value: 'value1, value2, valuen'}
If users don't select any options, the returned object structure is:
{selected: false}
Parameters
All parameters are required.
The showPicklistModal() function accepts the following parameters:
-
QUESTION_CODE(string) - Specifies the code of the input box question associated with the popup table or popup list answer. You can find the code in the Code field on the question record. -
ANSWER_CODE(string) - Specifies the code of the popup table or popup list answer to display to users. You can find the code in the Code field on the answer record.
Examples
The following examples show how to use the showPicklistModal() function.
Retrieving Selected Options from a Popup Table
This example prompts users to select color options from a popup table. When users select an option or close the popup window, the result is logged to the console to show whether a selection was made and which color was selected.
showPicklistModal('DESK_COLORS', 'OPTIONS').done((data) => {
console.log(data);
});