Pretty old thread, but I would be interested in an answer, too.
I am using a function, similar to the “globals.group_specific_value” described in Advanced Topics - Icinga 2 (just without the group part). I am using it to set a default value, just as in the example:
This is not possible for the UI to perform. It would require an API endpoint that allows to evaluate custom expressions. However, due to security concerns this is not an option.
This means it is a dynamic function and will be evaluated when it called. Since the value is not static it can’t be defined in vars.
If you scroll to the top of the inspection page and view the Executed Command you will see the actual output of that function alongside the parameter you defined in CheckCommand.