Context variable scope Group?

A flow I am constructing for a dashboard has multiple copies of the same nodes.
Untitled 4
(I mistyped "2")
It would be useful if I could define a context variable group.arrayidx so that the source of the data in each field could be the same msg.payload.contacts[goup.get("arrayidx")] instead of hard coding the index number msg.payload.contacts[2]

In this simple example I could use a change node to set msg.payload.contact = msg.payload.contacts[2] but more complicated dashboards have data derived from more than just one message.

Perhaps there is already an easy way to achieve this?

You could use a group env variable rather than a context var.

[{"id":"b7afaa489acfae78","type":"group","z":"d5835c53bc24f9f0","name":"","style":{"label":true},"nodes":["a88c4085ec5560c2","d42d2431bb6c0950"],"env":[{"name":"test","value":"aaa","type":"str"}],"x":274,"y":899,"w":452,"h":82},{"id":"a88c4085ec5560c2","type":"inject","z":"d5835c53bc24f9f0","g":"b7afaa489acfae78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"${test}","payload":"test","payloadType":"env","x":410,"y":940,"wires":[["d42d2431bb6c0950"]]},{"id":"d42d2431bb6c0950","type":"debug","z":"d5835c53bc24f9f0","g":"b7afaa489acfae78","name":"debug 117","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":940,"wires":[]}]

In a change node before the ui nodes you can do:-
set msg. a_property_name
to flow. arrayidx
Then in same change node you can do
set msg. whatever_property
to msg.
payload.contacts[msg.a_property_name]

Thanks.

I resolved this issue by routeing all the group input & output into a single function and used context.
If only the UI group could be dynamically set by a message property all would be great.

I must get round to looking at environment variables.

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