# Multiple property in Switch Node

**URL:** <https://discourse.nodered.org/t/multiple-property-in-switch-node/65353>\
**Category:** General\
**Created:** [20 July 2022 08:54 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353 "2022-07-20T08:54:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 July 2022 08:54 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/1 "2022-07-20T08:54:00Z")

</div>

Hello I would like to have only one switch for the mulptiple payload I want to test.  
But in a Switch Node we can put only one property I would like to put pultiple property because I need to add a new switch node for each test of my payload. I wan't only one switch node which do the work of all.  
Actually I have this :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6fdeedd6b9c00dbd35a1e83a96aef8334f2c2030.png)  
But I would like now to have this :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6d4e0d57451d0f63411a2bc65676ff8fb4fdf046.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [20 July 2022 09:06 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/2 "2022-07-20T09:06:16Z")

</div>

Can you give an example of the payloads you want to test against ?

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 July 2022 09:18 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/3 "2022-07-20T09:18:38Z")

</div>

Yes of course.  
I give you one example of switch :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a61190ddf0f1c7600c6e6d970c8229d63579584.png)  
And for each switch I have the same test rules bue not the same msg.payload  
The problem i that when my msg.payload.voltage is null I it returns the message that's why I used some switch.

I have this :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/4/245d43d2d83b89ee1ad965d4424974218d7e48b2.png)  
But I would like to have only one node for switch and one also for the treatment behind.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [20 July 2022 13:17 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/4 "2022-07-20T13:17:12Z")

</div>

Use a function

---

<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:** [20 July 2022 13:37 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/5 "2022-07-20T13:37:42Z")

</div>

You can select JSONata rather than `!=`, and do the comparison of different properties in a JSONata expression  
e.g.

```auto
[{"id":"e7e98c87.110e28","type":"switch","z":"30af2d3e.d94ea2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"$$.payload.voltage != null","vt":"jsonata"},{"t":"jsonata_exp","v":"$$.payload.current != null","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":1040,"wires":[[],[]]}]

```

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [21 July 2022 06:32 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/6 "2022-07-21T06:32:51Z")

</div>

Yes thanks you it's working

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [21 July 2022 06:34 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/7 "2022-07-21T06:34:11Z")

</div>

Yes I made this also there is different solutions thanks for your help !

---

<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:** [4 August 2022 06:35 UTC](https://discourse.nodered.org/t/multiple-property-in-switch-node/65353/8 "2022-08-04T06:35:03Z")

</div>

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