Forum Discussion

Henchway's avatar
Henchway
Contributor
4 years ago
Solved

Expression Library evaluates to ArrowFunction

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

  • 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')

5 Replies

  • tstack's avatar
    tstack
    Former Employee

    The “next” properties are expressions. So, I would think you could write an expression to check the response to the status request to see if it was completed or not. If it was completed, the ‘Has Next’ expression should return false, otherwise it should return true. The ‘Next URL’ can just be the same as the main Service URL property.