Ui-template in subflow, access subflow properties in template

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

this works as shown in the next picture

Screenshot1

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:

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

Screenshot2

[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

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

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

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 :slightly_smiling_face:

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