$lookupTable
Signature: $lookupTable(table, filterKeys, filterPredicates[, options])
Parameters:
- table - Source lookup table. All lookup tables are available inside $tables global variable
- filterKeys - String or array of strings of keys to filter on
- filterPredicates - One or more predicates to filter on. If filterKeys is an array, filterPredicates must be an array of the same length
-
options - Object with optional properties:
- wildcard - Wildcard string to use for matching. E.g. if set to ””, then “express_aero” will match “express_“.
Returns row from a lookup table where all filter conditions are satisfied. Supports wildcard matching. This function is provided by Chain.io and isn’t a part of the JSONata standard library.
Example
Given following lookup table named “shipping”:
| Key | Value | Preferred |
|---|---|---|
1
|
express
|
false
|
2
|
standard
|
false
|
2
|
overnight
|
true
|
3
|
express_*
|
false
|
| Expression | Result |
|---|---|
{'$lookupTable($tables.shipping, "key", "1").value'}
|
"express"
|
{'$lookupTable($tables.shipping, "key", "2").Preferred'}
|
["false", "true"]
|
{'$lookupTable($tables.shipping, ["key", "Preferred"], ["2", "true"]).value'}
|
"overnight"
|
{'$lookupTable($tables.shipping, "value", "express_aero", { "wildcard": "\*" }).key'}
|
"3"
|
{'$lookupTable($tables.shipping, "value", "express_other", { "wildcard": "\*" }).key'}
|
"3"
|
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article