# Help with SWITCH node - is there a way to OR options?

**URL:** <https://discourse.nodered.org/t/help-with-switch-node-is-there-a-way-to-or-options/35138>\
**Category:** General\
**Created:** [1 November 2020 00:06 UTC](https://discourse.nodered.org/t/help-with-switch-node-is-there-a-way-to-or-options/35138 "2020-11-01T00:06:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 November 2020 00:06 UTC](https://discourse.nodered.org/t/help-with-switch-node-is-there-a-way-to-or-options/35138/1 "2020-11-01T00:06:34Z")

</div>

This is a cut down example, but for the sake of showing the _problem_ (question)

If `msg.payload` **contains** `partly` it goes to output 1  
if `msg.payload` **contains** `scattered` it goes to output 2.  
_otherwise_ it goes to 3.

Ok. But for the sake of asking:  
If I have a few things which are **OR** , can I save outputs and tests and put them all one one line?

Then it would be more like:  
if `msg.payload` **contains** `partly` || `scattered` it goes to output 1

```auto
[{"id":"8469cd6d.ced9c","type":"switch","z":"703c61ac.837e1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"partly","vt":"str"},{"t":"cont","v":"scattered","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":390,"wires":[["ee25707a.a4a21"],["ee25707a.a4a21"],["9760d9dd.5b4b2"]]}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [1 November 2020 00:21 UTC](https://discourse.nodered.org/t/help-with-switch-node-is-there-a-way-to-or-options/35138/2 "2020-11-01T00:21:40Z")

</div>

Three methods  
1 use regex  
2 use jsonata  
3 use wires

Eg.

```auto
[{"id":"4fd0f248.01985c","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"hhh scattered hh","payloadType":"str","x":160,"y":2480,"wires":[["257a6f7a.a8c0d"]]},{"id":"3591244.8c0325c","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"hhh showers hh","payloadType":"str","x":150,"y":2520,"wires":[["257a6f7a.a8c0d"]]},{"id":"65c3ac83.00447c","type":"debug","z":"8d22ae29.7df6d","name":"Na Template","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":2520,"wires":[]},{"id":"257a6f7a.a8c0d","type":"switch","z":"8d22ae29.7df6d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"$contains(payload, \"(rainy|showers)\")","vt":"jsonata"},{"t":"regex","v":"(scattered|partly)","vt":"str","case":false},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":380,"y":2520,"wires":[["65c3ac83.00447c"],["65c3ac83.00447c"],[]]}]

```

I have only used 1 debug add more to see routing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 November 2020 00:21 UTC](https://discourse.nodered.org/t/help-with-switch-node-is-there-a-way-to-or-options/35138/3 "2020-11-15T00:21:43Z")

</div>

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