General functions
These functions let you display list items directly to respondents, for example in question text, or use them in custom code such as variable logic.
Generally, get functions are recommended for custom code, while print functions are recommended for displaying text to respondents.
The examples below reference a list called Q1List with the following items:
- Blue
- Green
- Red
- Yellow
getListItemLabel
Returns the label of a single list item at the specified position. If the position doesn't exist, undefined is returned.
Function: getListItemLabel(listName: string, position: number): string
Example 1: Why did you choose {{getListItemLabel("Q1List", 1)}}?
Return: Why did you choose Blue?
Example 2: Why did you choose {{getListItemLabel("Q1List", 5)}}?
Return: Why did you choose undefined?
getListItemLabelsArray
Returns the item text of all items in the specified list as a JavaScript array.
Function: getListItemLabelsArray(listName: string): string[]
Array: ["Blue","Green","Red","Yellow"]
Example 1: How do you feel about {{getListItemLabelsArray("Q1List")}}?
Return: How do you feel about Blue,Green,Red,Yellow?
Example 2: How do you feel about {{getListItemLabelsArray("Q1List")[0]}}?
Return: How do you feel about Blue?
getListItemNumber
Returns the source list item number at the specified position. If the position doesn't exist, undefined is returned.
Function: getListItemNumber(listName: string, position: number): number
Example 1: Why did you choose {{getListItemNumber("Q1List", 1)}}?
Return: Why did you choose 1?
Example 2: Why did you choose {{getListItemNumber("Q1List", 5)}}?
Return: Why did you choose undefined?
getListItemNumbersArray
Returns the source list item numbers of all items in the specified list as a JavaScript array.
Function: getListItemNumbersArray(listName: string): string[]
Array: ["1","2","3","4"]
Example 1: Why did you choose item {{getListItemNumbersArray("Q1List")}}?
Return: Why did you choose 1,2,3,4?
Example 2: Why did you choose item {{getListItemNumbersArray("Q1List")[0]}}?
Return: Why did you choose 1?
getListLength
Returns the number of items in a list.
Function: getListLength(listName: string): number
Example: The number of possible items is {{listLength("Q1List")}}.
Return: The number of possible items is 4.
listHasSourceItem
Returns true or false based on whether a source list item exists in a dynamic list.
Function: listHasSourceItem(listName: string, itemNumber: number): boolean
The examples below assume a dynamic list called ColorsChosen containing Blue (item 1) and Yellow (item 4).
Example 1: The list contains the item Blue: {{listHasSourceItem("ColorsChosen", 1)}}
Return: The list contains the item Blue: true
Example 2: The list contains the item Green: {{listHasSourceItem("ColorsChosen", 2)}}
Return: The list contains the item Green: false
Example 3: {{listHasSourceItem("ColorsChosen", 4) ? "Why do you like Yellow?" : "Why did you not choose Yellow?"}}
Return: Why do you like Yellow?
printListItemLabel
Returns the label of a single list item at the specified position. If the position doesn't exist, the function returns blank.
Function: printListItemLabel(listName: string, position:number): string
Example 1: How do you feel about {{printListItemLabel("Q1List", 1)}}?
Return: How do you feel about Blue?
Example 2: How do you feel about {{printListItemLabel("Q1List", 5)}}?
Return: How do you feel about ?
printListItemLabelsArray
Returns all item labels as a formatted, comma-delimited string intended for display to respondents. Does not behave like an array in custom code.
Function: printListItemLabelsArray(listName: string): string
Example 1: How do you feel about {{printListItemLabelsArray("Q1List")}}?
Return: How do you feel about Blue, Green, Red, Yellow?
Example 2: How do you feel about {{printListItemLabelsArray("Q1List")[3]}}?
Return: How do you feel about Blue, Green, Red, Yellow[3]?
printListItemNumber
Returns the source list item number at the specified position. If the position doesn't exist, the function returns blank.
Function: printListItemNumber(listName: string, position:number): number
Example 1: Why did you choose brand {{printListItemNumber("Q1List", 1)}}?
Return: Why did you choose brand 1?
Example 2: Why did you choose brand {{printListItemNumber("Q1List", 5)}}?
Return: Why did you choose brand ?
printListItemNumbersArray
Returns all item numbers as a formatted, comma-delimited string intended for display to respondents. Does not behave like an array in custom code.
Function: printListItemNumbersArray(listName: string): string
Example 1: How do you feel about {{printListItemNumbersArray("Q1List")}}?
Return: How do you feel about 1, 2, 3, 4?
Example 2: How do you feel about {{printListItemNumbersArray("Q1List")[3]}}?
Return: How do you feel about ?
