# Flow variable only works once

**URL:** <https://discourse.nodered.org/t/flow-variable-only-works-once/45548>\
**Category:** General\
**Created:** [12 May 2021 14:44 UTC](https://discourse.nodered.org/t/flow-variable-only-works-once/45548 "2021-05-12T14:44:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OrluckIndBJ](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@OrluckIndBJ](https://discourse.nodered.org/u/OrluckIndBJ)\
**Post date:** [12 May 2021 14:44 UTC](https://discourse.nodered.org/t/flow-variable-only-works-once/45548/1 "2021-05-12T14:44:49Z")

</div>

I have a dashboard dropdown setting a flow variable (name) and I am using it to set the email address for a notification. It works the first time it sends an email, after that my name variable clears out (in the context menu) and I get a send failed message in my flow. How can I set the variable and have it stay there until the next name is selected from the dashboard dropdown.

I removed the emails and email node properties from the code below.

```auto
[{"id":"cee6b4e8.6b5f38","type":"debug","z":"87fc7610.f11ba8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":260,"wires":[]},{"id":"2748c941.49ba66","type":"ui_dropdown","z":"87fc7610.f11ba8","name":"Machinist List on dashboard","label":"","tooltip":"","place":"Select option","group":"626ca449.4dfd8c","order":0,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Br J","value":"BJ","type":"str"},{"label":"Be M","value":"BM","type":"str"}],"payload":"","topic":"","x":120,"y":140,"wires":[["e1bc08c5.c4ae38"]]},{"id":"e1bc08c5.c4ae38","type":"change","z":"87fc7610.f11ba8","name":"","rules":[{"t":"set","p":"name","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":140,"wires":[["884d669d.eb3b48"]]},{"id":"884d669d.eb3b48","type":"debug","z":"87fc7610.f11ba8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":100,"wires":[]},{"id":"b3f7e7b4.598278","type":"e-mail","z":"87fc7610.f11ba8","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"email node","x":530,"y":340,"wires":[]},{"id":"834e2f72.66192","type":"change","z":"87fc7610.f11ba8","name":"","rules":[{"t":"move","p":"name","pt":"flow","to":"to","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":340,"wires":[["b3f7e7b4.598278","cee6b4e8.6b5f38"]]},{"id":"2b8b351a.6f877a","type":"inject","z":"87fc7610.f11ba8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Still waiting for Cycle Start M0 or M1","payloadType":"str","x":110,"y":340,"wires":[["834e2f72.66192"]]},{"id":"626ca449.4dfd8c","type":"ui_group","name":"Machinist List","tab":"22daeffd.b2613","order":1,"disp":true,"width":"6","collapse":false},{"id":"22daeffd.b2613","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<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:** [12 May 2021 15:33 UTC](https://discourse.nodered.org/t/flow-variable-only-works-once/45548/2 "2021-05-12T15:33:47Z")

</div>

In the Change node `move flow name` you are Moving flow.name to msg.to. By using Move that clears the source (which is the flow variable). Use Set msg.to To flow.name instead. That will not affect the flow variable.

---

<div class="post-metadata">

**Author:** ![OrluckIndBJ](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@OrluckIndBJ](https://discourse.nodered.org/u/OrluckIndBJ)\
**Post date:** [12 May 2021 17:24 UTC](https://discourse.nodered.org/t/flow-variable-only-works-once/45548/3 "2021-05-12T17:24:54Z")

</div>

Thank you. That makes complete sense, something so simple.

---

<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:** [26 May 2021 17:25 UTC](https://discourse.nodered.org/t/flow-variable-only-works-once/45548/4 "2021-05-26T17:25:04Z")

</div>

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