# Control the delay node with input from dashboard

**URL:** https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994
**Category:** General
**Created:** [25 August 2020 17:23 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994 "2020-08-25T17:23:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kushal](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kushal](https://discourse.nodered.org/u/Kushal)
#### Post date: [25 August 2020 17:23 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994/1 "2020-08-25T17:23:27Z")

</div>

I want to set "x" minutes and "y" minutes delay by using dashboard's numeric nodes.  
eg - if I set number 7 in the numeric node on the dashboard, the delay node will delay the messages for 7 minutes.  
The attached image explains the situation more clearly. Can we use "override delay with msg.delay" for both nodes? and how?  
I am new at node-red & javascript and not able to code this using function node. Please help!

 ![Delay Problem](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/a/2a382b1b04af58f1cd25128a082136bbbd9d5296.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [25 August 2020 17:47 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994/2 "2020-08-25T17:47:41Z")

</div>

Did you look at the `Help` tab for the node?

 ![Screen Shot 2020-08-25 at 1.47.03 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66f44d19f3284e9817bf97214e01be04c305151e.png)

You will need to add a `change` node between each `ui-numeric` node and `delay` node to copy the payload to msg.delay

{EDIT} ohh now I see the issue. each msh from the ui\_numeric node will also pop into the loop so ou will have to filter them out with a switch node. Give me a moment to create an example.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [25 August 2020 18:24 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994/3 "2020-08-25T18:24:35Z")

</div>

Here you go. The key is to store each delay (from the ui-numeric) into a separate flow variable and then in the loop, grab the flow variable and move it to msg.delay

 ![Screen Shot 2020-08-25 at 2.22.04 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03ed1092257be5b0211f840da5867127367dac57.png)

Here is the flow:

```auto
[{"id":"15195cb8.9b52f3","type":"inject","z":"d46a4272.d095b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"from inject","payload":"true","payloadType":"bool","x":140,"y":200,"wires":[["f3e907ec.4e9bb8"]]},{"id":"8881beaa.e689b8","type":"delay","z":"d46a4272.d095b8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":340,"wires":[["489b7481.8d36f4","7495a4ea.5ee71c"]]},{"id":"b6ff3e9a.d1e68","type":"ui_numeric","z":"d46a4272.d095b8","name":"","label":"Delay 1","tooltip":"","group":"8711d53.103de28","order":11,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"delay 1","format":"{{value}}","min":0,"max":10,"step":1,"x":420,"y":160,"wires":[["366cfbb5.c7cd84"]]},{"id":"bc451a11.b80f38","type":"ui_numeric","z":"d46a4272.d095b8","name":"","label":"Delay 2","tooltip":"","group":"8711d53.103de28","order":12,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"delay 2","format":"{{value}}","min":0,"max":10,"step":1,"x":720,"y":160,"wires":[["d4b76007.f26fb"]]},{"id":"bd30978e.3bd168","type":"delay","z":"d46a4272.d095b8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":780,"y":340,"wires":[["108cedcb.562a72","f3e907ec.4e9bb8"]]},{"id":"f3e907ec.4e9bb8","type":"change","z":"d46a4272.d095b8","name":"frog","rules":[{"t":"set","p":"payload","pt":"msg","to":"frog","tot":"str"},{"t":"set","p":"delay","pt":"msg","to":"delay1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":340,"wires":[["8881beaa.e689b8"]]},{"id":"489b7481.8d36f4","type":"change","z":"d46a4272.d095b8","name":"cat","rules":[{"t":"set","p":"payload","pt":"msg","to":"cat","tot":"str"},{"t":"set","p":"delay","pt":"msg","to":"delay2","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":340,"wires":[["bd30978e.3bd168"]]},{"id":"366cfbb5.c7cd84","type":"change","z":"d46a4272.d095b8","name":"","rules":[{"t":"set","p":"delay1","pt":"flow","to":"payload*1000","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"delay value","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[[]]},{"id":"d4b76007.f26fb","type":"change","z":"d46a4272.d095b8","name":"","rules":[{"t":"set","p":"delay2","pt":"flow","to":"payload*1000","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"delay value 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":220,"wires":[[]]},{"id":"108cedcb.562a72","type":"debug","z":"d46a4272.d095b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":420,"wires":[]},{"id":"7495a4ea.5ee71c","type":"debug","z":"d46a4272.d095b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":370,"y":420,"wires":[]},{"id":"8711d53.103de28","type":"ui_group","z":"","name":"delay input","tab":"69dce23.e7db49c","order":1,"disp":true,"width":"6","collapse":false},{"id":"69dce23.e7db49c","type":"ui_tab","z":"","name":"Delay test","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Kushal](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kushal](https://discourse.nodered.org/u/Kushal)
#### Post date: [26 August 2020 06:43 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994/4 "2020-08-26T06:43:16Z")

</div>

Thanks a lot! This is exactly what i was looking for. Now i understood how it works!

---

<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: [9 September 2020 06:43 UTC](https://discourse.nodered.org/t/control-the-delay-node-with-input-from-dashboard/31994/5 "2020-09-09T06:43:23Z")

</div>

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