Retrieve the value of a flow variable from another node into the JS file?

Hi everyone !

I'm currently creating a custom node and I have a problem.

Is it possible to retrieve the value of a flow variable from a change node into the js file of my custom node ?

I tried to use flow.get("value") like in custom function but I had this error in node-red: "ReferenceError: flow is not defined".

If someone have an idea please ?


The docs for accessing context from a node are here

In summary, to access flow context you use:

let flowContext = this.context().flow
let value = flowContext.get("value")

One thing you must be aware of when using context in a custom node is that the user might have configured a context store that requires asynchronous only access. The Change node deals with this under the covers for you, but in your node, you'd need to use the async functions as described here.

Thanks a lot knolleary ! It works .

Have a nice day .

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