You are here: Business Rules > Business Actions > Execute JavaScript > Using JavaScript with Lookup Tables

Using JavaScript with Lookup Tables

Transformation Lookup Tables are used to make replacements via the 'Lookup Table Home' binding.

This example lookup table has an ID of 'ColorReplacement':

The following JavaScript accesses the ColorReplacement lookup table and returns 'Green':

var output = lookupTableHome.getLookupTableValue("ColorReplacement", "leaf");
logger.warning(output); // WARNING: Green

The 'getLookupTableValue' method returns the original string if a match is not found. In this example, the original string 'orange' is returned:

var output = lookupTableHome.getLookupTableValue("ColorReplacement", "orange");
logger.warning(output); // WARNING: orange

Setting the 'Replace with default...' option on the Lookup Table returns the substitution value when a match is not found:

var output = lookupTableHome.getLookupTableValue("ColorReplacement", "rose");
logger.warning(output); // WARNING: NA

2017, Stibo Systems