# How to pass the msg parameters through a node?

**URL:** <https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787>\
**Category:** General\
**Created:** [27 February 2023 05:18 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787 "2023-02-27T05:18:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [27 February 2023 05:18 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/1 "2023-02-27T05:18:55Z")

</div>

Hi I guess my question topic is slightly wrong. Anyways Ill explain here in detail.

I have a Node A wanting to pass msg.(anythin) to Node C. But my Node B ( Being a custom node built by a community member) does not pass the msg through the node. Currently I found a solution of using the context to store and retrieve it in the next node. But I face few circular reference issues (That is not quite problem here). I wanted to ask if there are any other ways on how to pass those messages via that custom node or any node if the custom node doesnt return the msg param?

---

<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:** [27 February 2023 07:10 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/2 "2023-02-27T07:10:13Z")

</div>

Which custom node? If it is a well supported node then that should be fixed.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [28 February 2023 08:44 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/3 "2023-02-28T08:44:21Z")

</div>

I would be hesitant to save the message in a context var, as you may run in to concurrency (race) issues.

If custom node B is not outputting any msg (e.g. email node), then why not send the message to both B and C? and if the order is important (i.e. first send to B and then to C) than you can use a function node with 2 outputs, to B and to C, and send the msg sequentially:

```auto
node.send([msg,null]); // Send to B
return([null,msg]); // Send to C

```

If B is sending some output, and you need this output together with your original msg, then call B, receive its output back to A and then call C.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [28 February 2023 13:46 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/4 "2023-02-28T13:46:14Z")

</div>

I guess it depends on the specific situation you have, but you could use another wire to bypass node B.  
Then join the messages from A and B before sending to C.

Personally I think all nodes should pass original message properties wherever possible, and my pet hate is that they should also allow properties and topics to be set in the config to negate the need for so many switch and change nodes 🙄

Perhaps this could be a black mark in the node scoring system to encourage authors to fix this 😀

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [28 February 2023 16:34 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/5 "2023-02-28T16:34:04Z")

</div>

> [@Josh](#):
>
> a custom node built by a community member

Unless there's an obvious reason it can't be fixed, you should raise an issue on GitHub.

> [@Sean-McG](#):
>
> a black mark in the node scoring system

An earlier [discussion](https://discourse.nodered.org/t/nodes-that-erase-messages/70952) pointed out that not passing along the original message properties can make it impossible to use the node in a `link call` segment.

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [28 February 2023 19:16 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/6 "2023-02-28T19:16:54Z")

</div>

Node-red-contrib-iiot-jwt Node.The github link is [GitHub - BiancoRoyal/node-red-contrib-iiot-jwt: The JSON Web Token package for Node-RED.](https://github.com/BiancoRoyal/node-red-contrib-iiot-jwt)

---

<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:** [3 March 2023 14:31 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/7 "2023-03-03T14:31:06Z")

</div>

I see that someone has already submitted an[issue](https://github.com/BiancoRoyal/node-red-contrib-iiot-jwt/issues/20) for this.

In the meantime it is safe to save and restore to flow context, provided that you can be sure that you will not pass in another message before the previous one has been fully actioned and the values restored to the message. Otherwise the second message will overwrite the context values before they have been picked up.

If you can't guarantee that then you can use this flow to make sure only one message at a time passes through the save - jwt node - restore nodes.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d8c28262f423d001015f3b26cd0b45ac39effb95.png)

Replace the Some 'functions to be performed' and 'Some more stuff to do' nodes with your save - action - restore nodes.

```auto
[{"id":"b6630ded2db7d680","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":1700,"wires":[["ed63ee4225312b40"]]},{"id":"ed63ee4225312b40","type":"delay","z":"bdd7be38.d3b55","name":"Queue","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"_mcu":{"mcu":false},"x":290,"y":1700,"wires":[["d4d479e614e82a49","7eb760e019b512dc"]]},{"id":"a82c03c3d34f683c","type":"delay","z":"bdd7be38.d3b55","name":"Some more stuff to do","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"_mcu":{"mcu":false},"x":780,"y":1700,"wires":[["7c6253e5d34769ac","b23cea1074943d4d"]]},{"id":"2128a855234c1016","type":"link in","z":"bdd7be38.d3b55","name":"link in 1","links":["7c6253e5d34769ac"],"_mcu":{"mcu":false},"x":75,"y":1780,"wires":[["3a9faf0a95b4a9bb"]]},{"id":"7c6253e5d34769ac","type":"link out","z":"bdd7be38.d3b55","name":"link out 1","mode":"link","links":["2128a855234c1016"],"_mcu":{"mcu":false},"x":645,"y":1780,"wires":[]},{"id":"b23cea1074943d4d","type":"debug","z":"bdd7be38.d3b55","name":"OUT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":650,"y":1620,"wires":[]},{"id":"d4d479e614e82a49","type":"debug","z":"bdd7be38.d3b55","name":"IN","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":450,"y":1620,"wires":[]},{"id":"3a9faf0a95b4a9bb","type":"function","z":"bdd7be38.d3b55","name":"Flush","func":"return {flush: 1}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":false},"x":170,"y":1780,"wires":[["ed63ee4225312b40"]]},{"id":"7eb760e019b512dc","type":"function","z":"bdd7be38.d3b55","name":"Some functions to be performed","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":false},"x":530,"y":1700,"wires":[["a82c03c3d34f683c"]]},{"id":"e35f37deeae94860","type":"comment","z":"bdd7be38.d3b55","name":"Set the queue timeout to larger than you ever expect the process to take","info":"","_mcu":{"mcu":false},"x":250,"y":1580,"wires":[]}]

```

---

<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:** [2 May 2023 14:31 UTC](https://discourse.nodered.org/t/how-to-pass-the-msg-parameters-through-a-node/75787/8 "2023-05-02T14:31:20Z")

</div>

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