Flow context question

#1

Is it possible to get the contents of a flow context entry without hard-coding the name? For example: In one function I am doing a flow.set(name, {fields}); to populate a long list of flow variables with an object containing multiple properties. I would like to be able to query the variables dynamically based on messages coming into my function node so I can compare a state (whether a temp is within range or out of range,) compare timestamps, and then update the stored values.

0 Likes

#2

The first argument to flow.get is the context property name. How you provide that name is up to you. Hardcoded "foo", use msg.topic, use whatever you want that will evaluate to the property name as a string.

0 Likes

#3

I'd tried that with no luck, then I dissected the flow leading into it after reading your post and found a mistake that was keeping the property I was passing as the trigger from flowing through. Working like a charm now, and I only feel a little stupid.

0 Likes