# Search a Node for route the payload

**URL:** <https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632>\
**Category:** General\
**Created:** [19 July 2024 14:44 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632 "2024-07-19T14:44:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [19 July 2024 14:44 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/1 "2024-07-19T14:44:10Z")

</div>

Hi,

i'm searching for a node to route the payload switched from an externel signal.  
for example:  
send a payload "1" to the "route node" an all incoming payloads routed to OUT "1" / send a payload "2" to the "route node" an all incoming payloads routed to OUT "2"

so like a switch node with an external control input

thankx in advance

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 July 2024 14:49 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/2 "2024-07-19T14:49:50Z")

</div>

Hi @Flixm

You can achieve this with the core nodes, using a context value as the property the Switch node checks against.

1. Configure the Switch node to check the value of `flow.myRoute` - add as many outputs as you need.
2. Use a Change node to set the value of `flow.myRoute` to whatever value you want the Switch node to route for.

```auto
[{"id":"3cd91b448d4accf4","type":"switch","z":"98ff6cf1928b251c","name":"Switch on flow.myRoute","property":"myRoute","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":820,"wires":[["03df53234e82c0aa"],["c677a0ebfd976c4e"]]},{"id":"016748d2380cd914","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":820,"wires":[["3cd91b448d4accf4"]]},{"id":"03df53234e82c0aa","type":"debug","z":"98ff6cf1928b251c","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":800,"wires":[]},{"id":"c677a0ebfd976c4e","type":"debug","z":"98ff6cf1928b251c","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":840,"wires":[]},{"id":"3099cdc2953c801f","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":700,"wires":[["0966d770d6df4cb1"]]},{"id":"0966d770d6df4cb1","type":"change","z":"98ff6cf1928b251c","name":"Set to flow.myRoute to 1","rules":[{"t":"set","p":"myRoute","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":700,"wires":[[]]},{"id":"916af7e49843dd62","type":"inject","z":"98ff6cf1928b251c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":740,"wires":[["c1c4a8e838d92ee2"]]},{"id":"c1c4a8e838d92ee2","type":"change","z":"98ff6cf1928b251c","name":"Set to flow.myRoute to 2","rules":[{"t":"set","p":"myRoute","pt":"flow","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":740,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [19 July 2024 14:59 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/3 "2024-07-19T14:59:36Z")

</div>

Okay maybe i need need to explain it more detailed.

I have a payload which does not change but i want to route it to another target node.

So actually i use two gate nodes which working opposite to route the Payloads to another target.

hope that's better to understand

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2024 15:04 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/4 "2024-07-19T15:04:26Z")

</div>

@knolleary's suggestion should do what you want. Alternatively look at [node-red-contrib-msg-router (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-msg-router) which has not been updated for several years, but is maintained by a regular contributer here (@BartButenaers) so I am sure it is well supported.

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [20 July 2024 06:04 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/5 "2024-07-20T06:04:57Z")

</div>

Okay, i'll try it. I never worked with flows ... So I need a bit more experience.

I'll check your suggestions.

Thx

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [20 July 2024 06:40 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/6 "2024-07-20T06:40:18Z")

</div>

That's what i need!

i was a bit confused about the two not wired Nodes. After i connected them to the Main Switch it works like i need it.

Thanks for the quick answers.

---

<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:** [3 August 2024 06:40 UTC](https://discourse.nodered.org/t/search-a-node-for-route-the-payload/89632/7 "2024-08-03T06:40:21Z")

</div>

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