# Multiple times message triggering

**URL:** <https://discourse.nodered.org/t/multiple-times-message-triggering/26591>\
**Category:** General\
**Created:** [13 May 2020 12:00 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591 "2020-05-13T12:00:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhtar321h](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@akhtar321h](https://discourse.nodered.org/u/akhtar321h)\
**Post date:** [13 May 2020 12:00 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/1 "2020-05-13T12:00:09Z")

</div>

Hello Everyone,

I want to trigger a node a specified number of times with the help of function node.  
Please give me solution for that.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 May 2020 12:11 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/2 "2020-05-13T12:11:36Z")

</div>

> [@akhtar321h](#):
>
> I want to trigger a node a specified number of times with the help of function node.

Can you be specific please?

What node do you need to trigger? It may be there is some other means of achieving your goal if you explain what the end goal is.

How many times - variable amount of times - or - a fixed amount of times?

Why do you say you need the help of a function node?

> [@akhtar321h](#):
>
> Please give me solution for that.

Please give us what you have tried and I'm certain someone will help you out.

---

<div class="post-metadata">

**Author:** ![akhtar321h](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@akhtar321h](https://discourse.nodered.org/u/akhtar321h)\
**Post date:** [13 May 2020 12:17 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/3 "2020-05-13T12:17:06Z")

</div>

I am triggering one buffer node with the help of function node.  
But I want to trigger that buffer multiple times( Variable amount of times) with the help of function node.  
Or  
If any other method is there for triggering variable amount of times(Not manually), Please suggest.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 May 2020 12:21 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/4 "2020-05-13T12:21:37Z")

</div>

Are you referring to [this buffer](https://discourse.nodered.org/t/storing-data-into-node-red/26112/17)?  
you really should be specific - it is soo hard to help when so little information is provided.

No screen shots. No links. Please help us to help you.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 May 2020 12:29 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/5 "2020-05-13T12:29:24Z")

</div>

> [@akhtar321h](#):
>
> If any other method is there for triggering variable amount of times(Not manually),

You can set an inject to repeat output.

You can use a trigger node "resend every" until msg.reset is received

You can write a `for` loop in a function and use `msg.send`

Most (if not all) of this is in the very good [documentation](https://nodered.org/docs/) & tons of examples in the [flow library](https://flows.nodered.org/) that might help.

A good idea might be to attempt one of the above options and when you get stuck, come back & ask for help on a specific item if you get stuck.

---

<div class="post-metadata">

**Author:** ![akhtar321h](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@akhtar321h](https://discourse.nodered.org/u/akhtar321h)\
**Post date:** [13 May 2020 12:45 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/6 "2020-05-13T12:45:49Z")

</div>

How can I use for loop in function node for multiple triggering.  
Can you send me some sample code.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 May 2020 12:51 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/7 "2020-05-13T12:51:44Z")

</div>

> [@akhtar321h](#):
>
> How can I use for loop in function node for multiple triggering

Do you know any javascript? Its just a for loop.

```javascript
//loop 10 times
for(let i = 0; i < 10; i++){
  //do something here e.g. node.send(msg)
} 

```

And for node.send - [it is in the documentation](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously) - please also read [this page](https://nodered.org/docs/user-guide/messages) & learn it - it will help you greatly.

---

<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:** [12 July 2020 12:51 UTC](https://discourse.nodered.org/t/multiple-times-message-triggering/26591/8 "2020-07-12T12:51:56Z")

</div>

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