cancel
Showing results for 
Search instead for 
Did you mean: 

Expression Library evaluates to ArrowFunction

Henchway
Contributor

Hello,

i’m trying to nest a function in a map within an expression library, however what i get returned just the ‘callstack’ of the function.

Here’s the outcome:

[
{
"test":
"/* ArrowFunction @ line 5:10 */ () => __parent__.salesRegionMapper('accountableUnit', 8)"
}
]

The expression library is called like this:

lib.map.responsibleUnit['8']

Here is the expression library:

{
	"responsibleUnit": {
	   "10": "Delivery",
	   "9": "Operation",
	   "8" : () => __parent__.salesRegionMapper('accountableUnit', 8),
	   "16": "Tolling Services"
	   },
    "accountableUnit": [
	   [5, "Sales APAC"],
	   [7, "Sales EMENA"],
	   [8, "Sales EMENA"],
	   [19, "Sales LAM"],
	   [20, "Sales NAM"],
	   [21, "Sales Africa"],
	   [22, "Sales EMENA"],
	   [23, "Other"],
	   [24, "Sales EMENA"],
	   [37, "Tolling Services"],
	   [39, "Other"]   
	],
    salesRegionMapper: (mappingTable, value) => this[mappingTable].find(x => x[0] == value)[1],
}

How can i get the function to actually execute and not just be ‘listed’?

Best regards
Thomas

1 ACCEPTED SOLUTION

koryknick
Employee
Employee

Change your responsibleUnit to a function:

	"responsibleUnit": (opt) => match opt {
	   "10" => "Delivery",
	   "9" => "Operation",
	   "8" => this.salesRegionMapper('accountableUnit', 8),
	   "16" => "Tolling Services",
       _ => "unknown"
	   },

Then you can call as a function and it will drilldown to the salesRegionMapper function:
lib.testcall.responsibleUnit('8')

View solution in original post

5 REPLIES 5

Thank you, Kory, that worked perfectly!