How to access context in a change node using the J: method

Sorry, I know I've asked before but it is possible.

I want to do some maths on a context but can't remember how to do that trick.

I seem to remember in the change node you set it something like:
J: flow.get("something") * 2
and that will give me flow.get("something") value multiplied by 2.

But when I'm doing it now, I get undefined.

example / solution.
J: $globalContext("SCAN_TIME")

(Just incase anyone else is interested.)

Unless you need to do it dynamically, you can just do,
set msg. var
to global. SCAN_TIME

Only use JSONata if needed as it has overheads.

Just for others info.

1 Like

Thanks.

I'm not exactly sure about if that is or not FIXED.... I think most of the time it is, but I need it to be changed in this case dynamically if the global value is changed.....

Then I add a fudge factor to it.

So really it is:
J: $globalContext("SCAN_TIME") * 1.5 So there is wiggle room if the timing goes off.

But thanks for the reply.

Oh, and I did it this way to NOT use a function node.
(Though most of the time I shall say I am guilty of doing that. But to keep the memory working I thought it would be nice to do it in a change node instead.)
(Also to explain why I am doing it this way)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.