loadListWithArray()
The loadListWithArray() function (client-side) retrieves rows from a static or CSV table by applying filter conditions defined in a filter array. Various comparison operators are available for the filter conditions. For more information about static and CSV tables, see Creating Static Tables and Creating CSV Tables.
Syntax
The general syntax for the loadListWithArray() function is:
loadListWithArray('TABLE_CODE', filterArray);
For the filter conditions, use this syntax:
loadListWithArray('TABLE_CODE', [{'ColumnName1': 'Value1', 'cpqc-operator':
'operator1'}]);
Return Value
The loadListWithArray() function returns an array of objects. Each object in the array represents a row from the specified table that matches the criteria defined in the filter array. If no filters are provided, the function returns all table rows as objects within the array.
[
{
"columnName1": "value",
"columnName2": "value",
"columnName3": "value"
},
{
"columnName1": "value",
"columnName2": "value",
"columnName3": "value"
},
{
"columnName1": "value",
"columnName2": "value",
"columnName3": "value"
}
...
]
Parameters
The table code parameter is required.
The loadListWithArray() function accepts the following parameters:
-
TABLE_CODE- The code of the table to query. You can find it in the Code field on the table record. -
filterArray- An array of objects that specifies the filter conditions. Each object in the array represents a single filter. Each filter uses a key-value pair for the column name and its value, and an operator.The following operators are available for the
cpqc-operatorkey:Note:When this key is omitted, it defaults to
equalto.-
equalto -
greaterthan -
lessthan -
contains -
notequalto -
doesnotcontain -
lessorequalto -
greaterorequalto
-
Examples
The following examples show how to use the loadListWithArray() function.
Retrieving Rows Containing a Specific Value
This example returns rows in which the Type column contains the value Lamp in the table with the code ACCESSORIES_TABLE.
loadListWithArray('ACCESSORIES_TABLE', [{
'Type': 'Lamp',
'cpqc-operator': 'contains'
}]);
The resulting output may look like this:
[
{
"Accessory Code": "Lamp-A110",
"Type": "Lamp",
"Color": "Orange"
},
{
"Accessory Code": "Lamp-A111",
"Type": "Lamp",
"Color": "Blue"
},
{
"Accessory Code": "Lamp-A112",
"Type": "Lamp",
"Color": "Yellow"
}
]