# Function node, how to send text out 5 times to debug node?

**URL:** <https://discourse.nodered.org/t/function-node-how-to-send-text-out-5-times-to-debug-node/85527>\
**Category:** General\
**Created:** [14 February 2024 12:05 UTC](https://discourse.nodered.org/t/function-node-how-to-send-text-out-5-times-to-debug-node/85527 "2024-02-14T12:05:20Z")\
**Posts on this page:** 2\
**Page:** 2

<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:** [14 February 2024 21:13 UTC](https://discourse.nodered.org/t/function-node-how-to-send-text-out-5-times-to-debug-node/85527/21 "2024-02-14T21:13:01Z")

</div>

> [@E1cid](#):
>
> > [@Colin](#):
> >
> > Since `node.send()` does not clone the message a
> 
> That is not what the docs say

Oh, I have been spreading fake news all these years. How on earth did I miss that change?

However, that text is somewhat confusing (I think). When it refers to the first message I think it does not mean in the situation that we have here, with a sequence of send(msg) statements. It relates to the condition where one node.send() is used to send a sequence of messages. Something like  
`node.send([[msg,msg,msg]])`  
so in NR before 1.0 that would not clone the first msg but would clone the rest. Now it will clone all of them unless `false` is passed, in which case it will not clone the first one. In the case of send with only one message being sent (or a sequence of sends each with only one message) then the boolean parameter tells it whether or not to clone that message.

Looking at this I realise that that @questuk's requirement can be satisfied with a Function node containing just

```auto
if (msg.payload >= 80)
{
   msg.payload = "Humidity exceeded ... in the ,,, LOFT ... Module ,, Twenty Five ... "
   node.send([[msg,msg,msg,msg,msg]]); // send multiple clones of the message
}

```

In case anyone wants to confirm how the cloning works then here is a simple flow demonstrating various conditions

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/3546f0ccb63b225694abb056b30e7e558d85c8a0.png)

```auto
[{"id":"fddda6a178227ed1","type":"inject","z":"bdd7be38.d3b55","name":"Default","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":250,"y":5780,"wires":[["f11d19c6af0ca7bf"]]},{"id":"f11d19c6af0ca7bf","type":"function","z":"bdd7be38.d3b55","name":"send(msg)","func":"msg.payload = 1\nnode.send(msg)\nmsg.payload++\nnode.send(msg)\nmsg.payload++\nnode.send(msg)\nreturn null","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":5780,"wires":[["940c6dc5e6e48f31"]]},{"id":"940c6dc5e6e48f31","type":"debug","z":"bdd7be38.d3b55","name":"debug 2499","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":5860,"wires":[]},{"id":"addff4c239639ec6","type":"inject","z":"bdd7be38.d3b55","name":"no clone","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":260,"y":5840,"wires":[["c62dd3b69d46dd01"]]},{"id":"c62dd3b69d46dd01","type":"function","z":"bdd7be38.d3b55","name":"send(msg, false)","func":"msg.payload = 1\nnode.send(msg,false)\nmsg.payload++\nnode.send(msg, false)\nmsg.payload++\nnode.send(msg, false)\nreturn null","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":5840,"wires":[["940c6dc5e6e48f31"]]},{"id":"4be8e9aaed4afea9","type":"inject","z":"bdd7be38.d3b55","name":"Default multi","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":270,"y":5900,"wires":[["92c9cdcc7e7f1b5f"]]},{"id":"92c9cdcc7e7f1b5f","type":"function","z":"bdd7be38.d3b55","name":"send([[msg,msg,msg]])","func":"msg.payload = 1\nnode.send([[msg,msg,msg]])\nmsg.payload = \"oops\"\nreturn null","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":5900,"wires":[["940c6dc5e6e48f31"]]},{"id":"bc7191e041772909","type":"inject","z":"bdd7be38.d3b55","name":"Default multi false","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":290,"y":5960,"wires":[["96f48d649aeba089"]]},{"id":"96f48d649aeba089","type":"function","z":"bdd7be38.d3b55","name":"send([[msg,msg,msg]], false)","func":"msg.payload = 1\nnode.send([[msg,msg,msg]], false)\nmsg.payload = \"oops\"\nreturn null","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":5960,"wires":[["940c6dc5e6e48f31"]]},{"id":"88e2b935ceb06e23","type":"inject","z":"bdd7be38.d3b55","name":"Default multi false preceeded by default","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":350,"y":6020,"wires":[["21e2da34e3439ac7"]]},{"id":"21e2da34e3439ac7","type":"function","z":"bdd7be38.d3b55","name":"send(msg); send([[msg,msg,msg]], false)","func":"msg.payload = 1\nnode.send(msg)\nnode.send([[msg,msg,msg]], false)\nmsg.payload = \"oops\"\nreturn null","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":6020,"wires":[["940c6dc5e6e48f31"]]}]

```

---

<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:** [14 May 2024 21:13 UTC](https://discourse.nodered.org/t/function-node-how-to-send-text-out-5-times-to-debug-node/85527/22 "2024-05-14T21:13:42Z")

</div>

Closed on 14 May 2024 21:13 UTC

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

[Previous page](https://discourse.nodered.org/t/function-node-how-to-send-text-out-5-times-to-debug-node/85527.md?page=1)
