Can't get most basic jsonata expression right in change node. I need to route mesage to two different outputs depending on the topic ... (topic = "A") seems to work but boolean (topic = "B" or topic = "C") doesn't. Thanks.
If you want to route two different message types, not sure why you want a change node since this can be done with a switch node and without JSONata.
I meant switch node. How do you route in case of (topic = "B" or topic = "C")
For first output 1 need it to be A (no problem with that), for output 2 I need to be B "or" C
Add all 3 & connect the B and C outputs together with a junction node or direct to the next node.
Ok, or can just send B and C into the same place (without junction node)? I just wanted to do a jsonata boolean, didn't expect that wouldn't be able to solve it.
Yes, certainly. A junction can be convenient though and may help keep the visuals tidy.
JSONata can certainly do the job but it is a rather large industrial steam hammer to knock in a nail.
JSONata adds significant overheads to your flow and is generally best kept for when nothing else fits or you need an object re-shaping (which is what it was originally for I believe).
You don't need a junction node, just feed the two outputs to the same place.
The output of $$.topic ="B" or $$.topic = "C" is a boolean so just add that as the expression.
e.g.
[{"id":"01a5fa39c9c56b5a","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"A","payload":"1","payloadType":"str","x":870,"y":7760,"wires":[["5742f760b0672199"]]},{"id":"5742f760b0672199","type":"switch","z":"d1395164b4eec73e","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"A","vt":"str"},{"t":"jsonata_exp","v":"$$.topic = \"B\" or $$.topic = \"C\"","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":2,"x":1070,"y":7780,"wires":[["d890d64db2e56f8a"],["d09f296836f763f2"]]},{"id":"02b40896f488c50d","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"B","payload":"2","payloadType":"str","x":870,"y":7820,"wires":[["5742f760b0672199"]]},{"id":"f539489f4164f71c","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"C","payload":"3","payloadType":"str","x":870,"y":7880,"wires":[["5742f760b0672199"]]},{"id":"d890d64db2e56f8a","type":"debug","z":"d1395164b4eec73e","name":"debug 2575","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":7760,"wires":[]},{"id":"d09f296836f763f2","type":"debug","z":"d1395164b4eec73e","name":"debug 2576","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":7800,"wires":[]}]
Or if those are the only two outputs ("a" , "b" or "c") you could always use otherwise for second rule.
