# Subflow - pass a payload value as input value on subflow

**URL:** <https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816>\
**Category:** General\
**Created:** [20 December 2020 21:26 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816 "2020-12-20T21:26:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsoares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nsoares/32/34031_2.png) [@nsoares](https://discourse.nodered.org/u/nsoares)\
**Post date:** [20 December 2020 21:26 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/1 "2020-12-20T21:26:19Z")

</div>

Hi all.

I'm trying to pass a payload value as a input value on a subflow node.  
How can I pass the current msg.data.state value to subflow ?

 ![Screenshot 2020-12-20 at 18.43.01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b13c26efc0ade782d57c04371d5ac326142c4af3.png)

Thanks in advance for the help & time.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 December 2020 21:29 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/2 "2020-12-20T21:29:17Z")

</div>

Hi @nsoares, welcome to the forum.

The subflow properties act as environment variables inside the subflow - they are evaluated when the subflow is first started and cannot be changed dynamically.

---

<div class="post-metadata">

**Author:** ![nsoares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nsoares/32/34031_2.png) [@nsoares](https://discourse.nodered.org/u/nsoares)\
**Post date:** [20 December 2020 21:34 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/3 "2020-12-20T21:34:33Z")

</div>

Thanks @knolleary. Great tool!

So I can only pass a static value into a subflow that will be used by the Eviroment Vaiables ??? This value cannot come from a payload value ??

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 December 2020 21:35 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/4 "2020-12-20T21:35:40Z")

</div>

You cannot set a Subflow Property from a message property.

But you can, of course, message messages into the subflow and use its properties within the flow as you would a normal form. You just cannot use message properties to set subflow properties.

---

<div class="post-metadata">

**Author:** ![nsoares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nsoares/32/34031_2.png) [@nsoares](https://discourse.nodered.org/u/nsoares)\
**Post date:** [20 December 2020 21:39 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/5 "2020-12-20T21:39:10Z")

</div>

Sorry..I'm new at this.  
What do you mean by "message messages" ?  
Can you share an example for better understanding?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 December 2020 21:51 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/6 "2020-12-20T21:51:49Z")

</div>

Sorry - that was a typo.

I meant to say you can **pass** messages into the subflow and use its properties within the flow as you would another flow.

---

<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:** [20 December 2020 21:52 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/7 "2020-12-20T21:52:46Z")

</div>

Hopefully nick won't mind me helping here. I suspect that was a typo and he meant 'send messages' or something similar. So if you want to use a value that is in msg.data.state then you can just pass that message into the subflow and use nodes in there to take whatever action you need based on that state. So for example you might use a Switch node configured to test that value and send the message down different paths dependent on the value, or indeed on whether msg.data.state is present in the message at all.

---

<div class="post-metadata">

**Author:** ![nsoares](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nsoares/32/34031_2.png) [@nsoares](https://discourse.nodered.org/u/nsoares)\
**Post date:** [20 December 2020 22:43 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/8 "2020-12-20T22:43:16Z")

</div>

Got it ! Thanks to all! Really helpful

---

<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:** [18 February 2021 22:43 UTC](https://discourse.nodered.org/t/subflow-pass-a-payload-value-as-input-value-on-subflow/37816/9 "2021-02-18T22:43:43Z")

</div>

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