Can a Change node access its own context?

In the configuration of the Change node I can access flow and global context by choosing flow. or global. from the dropdown.

But can it not access its own context? There is no context. in the dropdown.

For example I if I want to compare a value with the value from the previous message I could load the value of the previous message from a context field and then put the value from the current message into the context field. There's no need to have this in flow context, node-local context would be sufficient.

I think you may need to use a function node for that.

Eg:

let old = context.get("OLD") || null;
let new = msg.payload;
if (old == new)
{
    //  do your stuff here as they are different.
}
else
{
    // They are different
    context.set("old",new);
    return;
}

That is a BASIC (and long) version of what I believe you are trying to do.
Oh, somewhere in there you need to return msg.
I don't know what you want to do so have left that part out.

I and others have raised this feature request in the past and I think Nick is quite happy for someone to come up with a PR to implement it

But it's not a priority for the core team

There is this often missed feature in the switch node

1 Like

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