# Ui-template in subflow, access subflow properties in template

**URL:** <https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [27 July 2024 09:34 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809 "2024-07-27T09:34:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RedTom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/redtom/32/88014_2.png) [@RedTom](https://discourse.nodered.org/u/RedTom)\
**Post date:** [27 July 2024 09:34 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809/1 "2024-07-27T09:34:30Z")

</div>

Hi,

I have an ui-template in a subflow,  
It has a variable label which I want to set by the subflow properties.  
For test I added a textfield to the subflow with Label={label}.  
I added an inject node which injects a message "msg.label=${label}" to my ui-template.

![Screenshot-subflow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be42214fec6c7a79b8bcc1508c0ed30f2a9e38d3.jpeg)

this works as shown in the next picture

![Screenshot1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/05719b0895c675ea65482ec2ac06802c6c64e098.jpeg)

after that i can refresh the page with F5 and nothing changes. When I click on my control, make some interaction, and then  
refresh the page, the label is reset to the initial value hard decoded in the subflow:

```auto
data() {
    return {
        value: "OFF",
        label: "RoomX",
...
};

```

![Screenshot2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1995756cbce2440dd4569760de6d36fda049f3c.jpeg)

```auto
[subflow-shutter.json|attachment](upload://amWbG6aOe5S3Q7hZRWtd9u6jIDI.json) (8.5 KB)

```

Is there a better way to access the property "label". How can I avoid that it is reset to the default value ?

thanks  
Thomas

---

<div class="post-metadata">

**Author:** ![RedTom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/redtom/32/88014_2.png) [@RedTom](https://discourse.nodered.org/u/RedTom)\
**Post date:** [27 July 2024 12:59 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809/2 "2024-07-27T12:59:49Z")

</div>

Hi,

after thinking some time about the problem, I understand that the ui-template runs client side and therefor the setup with the inject node  
does not work.  
I changed the label to be setup by msg.payload.label and added this to every message to the ui template.  
As I understand after refresh the last received message is repeated and this now includes the label.

Anyway is there a solution to use subflow properties for this ?

thanks  
Thomas

---

<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:** [27 July 2024 15:22 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809/3 "2024-07-27T15:22:43Z")

</div>

> [@RedTom](#):
>
> is there a solution to use subflow properties for this

A subflow property is effectively an environment variable, so you can pick it up in a Change node, for example, using `${property_name}`.  
[https://nodered.org/docs/user-guide/environment-variables](https://nodered.org/docs/user-guide/environment-variables)

---

<div class="post-metadata">

**Author:** ![RedTom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/redtom/32/88014_2.png) [@RedTom](https://discourse.nodered.org/u/RedTom)\
**Post date:** [27 July 2024 16:16 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809/4 "2024-07-27T16:16:45Z")

</div>

thanks,

i put a change node in the subflow before the ui-template with the property,  
so i don't need any more a change node before every subflow instance.  
Simplifies the things a little bit more 🙂

---

<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 August 2024 16:17 UTC](https://discourse.nodered.org/t/ui-template-in-subflow-access-subflow-properties-in-template/89809/5 "2024-08-26T16:17:06Z")

</div>

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