# Support multiline strings having environment variables in change node

**URL:** https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518
**Category:** Feature Requests
**Created:** [30 November 2021 13:03 UTC](https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518 "2021-11-30T13:03:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)
#### Post date: [30 November 2021 13:03 UTC](https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518/1 "2021-11-30T13:03:12Z")

</div>

I am using a `change` node to produce a long string where several parts need to be replaced by the value of environment variables. See example here below:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f468741a83696604e6575d7cb76ce6a67790e13.png)

This functionally works perfect but the problem is that

- it is not very convenient to edit / review such long strings as only a small part is visible in the editor.
  - moreover the string is actually a multiline string while it is shown as a single line string in the editor which also makes it harder to edit / review.

FYI in my case the multiline string =

```auto
from(bucket: "${INFLUXDB_BUCKET}")    
|> range(start: -30d, stop: now())   
|> filter(fn: (r) => r._measurement == "${INFLUXDB_MEASUREMENT}" and 
                       r._field == "steps" and
                        r.wearer == "${INFLUXDB_MIBAND_OWNER}") 
|> keep(columns: ["_time"])   
|> sort(columns: ["_time"], desc: false)   
|> last(column: "_time")

```

Maybe the template node can be used instead but I don't know how I then should specify environment variables in the template.

---

<div class="post-metadata">

### Author: ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)
#### Post date: [30 November 2021 13:11 UTC](https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518/2 "2021-11-30T13:11:43Z")

</div>

I see that the idea of extending the `template` node so that it also supports environment variables has been raised in the past:

- [Subflow - template node - subflow properties - #5 by knolleary](https://discourse.nodered.org/t/subflow-template-node-subflow-properties/23658/5)

That would also be a good solution for this issue.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [30 November 2021 15:11 UTC](https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518/3 "2021-11-30T15:11:57Z")

</div>

> [@janvda](#):
>
> Maybe the template node can be used instead but I don't know how I then should specify environment variables in the template.

Template currently only supports the msg along with flow and global vars as you've discovered. The workaround is to use a change node before the template to add the env vars to the msg as new properties.

Alternatively, if the environment vars are actaully set prior to the launch of Node-RED, you can pass them into global vars in settings.js of course. Though that doesn't help with the handy env vars you can set in groups and sub-flows.

Another alternative would be not to use env vars but rather global or flow vars. That would work in some but probably not all situations.

* * *

However, I agree that since the use of env vars in Node-RED is steadily expanding, making them available to the template node and possibly JSON as well would be a nice addition.

---

<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: [29 January 2022 15:12 UTC](https://discourse.nodered.org/t/support-multiline-strings-having-environment-variables-in-change-node/54518/4 "2022-01-29T15:12:40Z")

</div>

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