Is it possible to synchronize the contents of a node across multiple flows?
I'm using a change node to change one part of a message that can come in from multiple http endpoints and each endpoint has it's own separate work flow.
My thought is maybe to use a stored file and function node so that I only have to edit the one file instead of four change nodes.
Store the contents in a global context variable, then have all change nodes read the global variable.
Or use Link Call nodes to run the common code in one flow.
I thought of using link nodes but each flow has it's own workflow and needs to be seperate.
Each change node has multiple of the following:
Change - msg.site - Search for xyz and replace with zyx
I think I need to move away from the change node and into something custom to achieve what I'm looking for.
Difficult to give examples when you do not share enough info, but you could do all the search and replace in change node with JSONata and then save to context. Really need to see a example of what you are doing.
[{"id":"25997d3c0fa37a57","type":"change","z":"d03c03b6d2f91f47","name":"Change Serial To Site","rules":[{"t":"change","p":"site","pt":"msg","from":"123456789","fromt":"str","to":"Site_845","tot":"str"},{"t":"change","p":"site","pt":"msg","from":"123456799","fromt":"str","to":"Site_855","tot":"str"},{"t":"change","p":"site","pt":"msg","from":"12585978","fromt":"str","to":"Site_865","tot":"str"},{"t":"change","p":"site","pt":"msg","from":"123789456","fromt":"str","to":"Site_875","tot":"str"},{"t":"change","p":"site","pt":"msg","from":"132456789","fromt":"str","to":"Site_885","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"site","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1200,"wires":[[]]}]
Setting all sites in global sites
Then in each change node you can use
set msg.
topic
to value of global.
sites[msg.site]
e.g.
[{"id":"e97fe89bc18cc3e9","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"site","v":"12345","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":4080,"wires":[["e62ab11ec7c1750a"]]},{"id":"e62ab11ec7c1750a","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"sites[msg.site]","tot":"global"},{"t":"set","p":"payload","pt":"msg","to":"sites[msg.site]","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":4100,"wires":[["fee79774d31c98c4"]]},{"id":"5ae1e20717632d23","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"site","v":"12346","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":4140,"wires":[["e62ab11ec7c1750a"]]},{"id":"fee79774d31c98c4","type":"debug","z":"b9860b4b9de8c8da","name":"debug 307","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":4080,"wires":[]},{"id":"e477268b9da7d96c","type":"inject","z":"b9860b4b9de8c8da","name":"set global sites","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":3980,"wires":[["25997d3c0fa37a57"]]},{"id":"25997d3c0fa37a57","type":"change","z":"b9860b4b9de8c8da","name":"gloabl sites","rules":[{"t":"set","p":"sites","pt":"global","to":"{\t \"12345\": \"site1\",\t \"12346\": \"site2\"\t}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3980,"wires":[[]]}]
Then you only need to edit the global to make changes.
Still a guess as we have no idea the value and format of msg.site.
Very cool. Thanks for that.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.