# Subflows, putting $env variable names into fields of \`switch\` node

**URL:** <https://discourse.nodered.org/t/subflows-putting-env-variable-names-into-fields-of-switch-node/74148>\
**Category:** General\
**Created:** [25 January 2023 03:11 UTC](https://discourse.nodered.org/t/subflows-putting-env-variable-names-into-fields-of-switch-node/74148 "2023-01-25T03:11:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 03:11 UTC](https://discourse.nodered.org/t/subflows-putting-env-variable-names-into-fields-of-switch-node/74148/1 "2023-01-25T03:11:16Z")

</div>

Today's problem:

Subflow.  
$env variable used to make it usable on multiple devices.

Because `subflows` are limited to `1` input, I am putting a `switch` node just inside the `subflow` to direct ~~traffic~~ messages as needed.

So I have $DN _(DeviceName)_ set.  
I want to put that in as part of the field in the `switch` node.

```auto
[{"id":"541720ad73579447","type":"switch","z":"94cf2ea396e5b6f6","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"A1/stat/POWER","vt":"str"},{"t":"eq","v":"A1/tele/LWT","vt":"str"},{"t":"eq","v":"button","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":200,"y":160,"wires":[["61843ca1684f9f9d"],["4788b5265af1d45a"],["5b8cd9fe254ea8d1"]]}]

```

Where the `A1` is what will be defined in the `$DN`.

So - guessing - would `J$ $DN/stat/power` work?  
Ok: rhetorical. I'll try it.  
But if I didn't ask, it wouldn't work and I would have to ask it anyway. 😉

---

<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 March 2023 03:11 UTC](https://discourse.nodered.org/t/subflows-putting-env-variable-names-into-fields-of-switch-node/74148/2 "2023-03-26T03:11:38Z")

</div>

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