# How to STOP flows interactions

**URL:** <https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, function-node\
**Created:** [26 February 2022 10:55 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017 "2022-02-26T10:55:03Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 10:55 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/1 "2022-02-26T10:55:03Z")

</div>

i have two counters in two different flows, somehow when i stopped the first counter and start the other it started where the first stops , it doesnt start from zero, how to fix this? thx in advance

---

<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:** [26 February 2022 11:05 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/2 "2022-02-26T11:05:31Z")

</div>

You will have to share more details if you want help I'm afraid.

We have no idea what is in your flows, what nodes you are using etc.

If I were a gambling man, I would guess you are using the same global context variable in both "counters"?

---

<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:** [26 February 2022 11:11 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/3 "2022-02-26T11:11:56Z")

</div>

Or perhaps you are using a contrib counter node? If so then tell us which one you have installed.

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 11:15 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/4 "2022-02-26T11:15:57Z")

</div>

i m using a counter FUNCTION with this code below..with a start and stop buttons and a digital display..i copy pasted the flow the group flow is changed to test1 and test2

var counter = flow.get("counter") || 0  
counter ++  
flow.set("counter", counter)  
msg.payload = counter  
return msg;

---

<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:** [26 February 2022 11:17 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/5 "2022-02-26T11:17:21Z")

</div>

> [@noobmaster](#):
>
> changed to test1 and test2

1. Changed what - the function name?

2. How do you reset this?

3. Are both functions on the same TAB

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 11:24 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/6 "2022-02-26T11:24:22Z")

</div>

test1 and test2 are the two dashboard group nodes, below each group nodes we have two buttons one function and one digital display

1 -function name stayed the same  
2-i m working to add a rest option if you can help 🙂  
3- i m not sure if both functions are on the same tab i dont know where check it

glad for you help

---

<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:** [26 February 2022 11:26 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/7 "2022-02-26T11:26:24Z")

</div>

> [@noobmaster](#):
>
> i m not sure if both functions are on the same tab i dont know where check it

By function then I presume you are talking about Function nodes. In the editor where you can see the function node then you are looking at a tab. Is the other function node also visible in that tab or is it in a different tab in the editor?

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 11:27 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/8 "2022-02-26T11:27:44Z")

</div>

same tab 😅

---

<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:** [26 February 2022 11:28 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/9 "2022-02-26T11:28:04Z")

</div>

Then that is your problem.

flow context is shared across all nodes in 1 tab.

---

<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:** [26 February 2022 11:29 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/10 "2022-02-26T11:29:35Z")

</div>

That is the problem then. Flow context applies to a tab in the editor. If you wish to use the same flow context variable name then you must put the other function node in a different tab. Or use node context if if the counter context variable is not needed outside the function.

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 11:33 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/11 "2022-02-26T11:33:45Z")

</div>

its working you saved my day 😁

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 11:34 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/12 "2022-02-26T11:34:22Z")

</div>

thx its working 😁

---

<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:** [26 February 2022 13:31 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/13 "2022-02-26T13:31:40Z")

</div>

You can avoid the problem by using the node context rather than flow context, as node context is specific to each node instance.  
You said you needed a reset option. You could do that by defining that if msg.topic is "Reset" then reset the counter. Then (using node context) you might end up with something like this (untested):

```auto
let counter = context.get("counter") || 0
if (msg.topic === "Reset") {
  // reset the counter
  counter = 0
} else {
  counter++
}
context.set("counter", counter)
msg.payload = counter
return msg;

```

---

<div class="post-metadata">

**Author:** ![noobmaster](https://avatars.discourse-cdn.com/v4/letter/n/ecb155/32.png) [@noobmaster](https://discourse.nodered.org/u/noobmaster)\
**Post date:** [26 February 2022 13:45 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/14 "2022-02-26T13:45:08Z")

</div>

😁 thanks MrColin

---

<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 March 2022 13:45 UTC](https://discourse.nodered.org/t/how-to-stop-flows-interactions/59017/15 "2022-03-12T13:45:30Z")

</div>

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