Undefined variable, and i don't know why

This is what i am trying to do from icinga console :

<6> => node = "lubshvh52"
null
<7> => schedule = "hv_dm_chv09_wawssql12"
null
<8> => get_services(node).filter((sv) => match("*" + schedule, sv.name))
                                                     ^^^^^^^^
<8>: get_services(node).filter((sv) => match("*" + schedule, sv.name))
                                                   ^^^^^^^^
Error while evaluating expression: Tried to access undefined script variable 'schedule'

<9> => node
"lubshvh52"
<10> => schedule
"hv_dm_chv09_wawssql12"
<11> => 

Replacing schedule with static string works, but i’d like to use a variable. What am i doing wrong here?

You might need to import the variable into the function scope:

function() use(that) { ... }

Though, I don’t know how to apply this to the arrow syntax.

You can use the variable just as Johannes suggested for the arrow syntax as well.

<8> => get_services(node).filter((sv) use(schedule) => match("*" + schedule, sv.name))
1 Like