Can a node refer to itself using JSONata?

With JSONata, am I able to refer to the node itself? See image. I would like the JSONata expression to result in global.foobar. Currently, it is taking the information of the previous payload (msg.data.entity_id), which I do not need.

Imgur

No. JSONata expressions do not have access to node properties. They can only access msg properties.

1 Like

Not doubting what you're saying, but I did find how to do it. This was able to refer to the node itself.

$globalContext($substringAfter($entity().entity_id,"."))

Is your node-red the HA addon ?

I ask as the $entity() appears to be jsonata function added by HA

It is, yea. Ah gotcha, so not native to NR, but rather added by HA.

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