How to access a global variable from the JS function?

Hi there,

is there some sort of special variable defined in the JS scope that I can use to grab the global variable?

Your resolved application and workflow globals are always on the initial workflow payload at the property globals. In your case, you are setting a “Function Scope Path” of data.loop on your Function Node, which limits what is passed in to the node’s scope. Nothing is exposed outside of that.

If you were not setting that property, you could access the globals at payload.globals; but if you must set the property, you will first have to copy/move your globals into that object you are setting as the Function Node’s scope.

Easiest way to do that is a Mutate Node, moving or copying globals into data.loop.

1 Like

Oh right! I used the second approach that makes sense.