Using Input in subflow

Hi. I have a problem. - I have made a subflow with one input-port called Entitet. How do i use that value in code, where i build a payload?

I have tryed this: msg.payload.data.entity_id = "{Entitet}"; - But that actualy just returns a string contaning {Entitet} ... So, there must be another way!

Hi @ckvist72, welcome to the forum.

Can you explain a bit more what you mean about having an input-port called Entitet?

Subflows don't have named inputs in that way. The messages are passed into the subflow just as they would be passed into any other node.

So if you pass a subflow a message with msg.payload = "foo", then in a Function node within that Subflow, you'd use msg.payload just as you would outside of the subflow.

I can try. I have attached an image, showing the input-port on the sub-flow i'm talking about. Hope it makes sence... - Renamed it to ENT ... Just to write something shorter. :slight_smile:

Sorry. forgot. When i call the subflow i set it this way:
2020-11-27 22_48_07-Node-RED - Home Assistant – Google Chrome

As the edit dialog in the first screenshot shows, these are handled as environment variables within the subflow.

In the function node, you can use env.get("ENT") to get its value.

1 Like

I also thought so ... But i do get a blank value, if i do this. - and not the value test

Sorry. This reply was to the other post.

I also thought so ... But i do get a blank value, if i do this. - and not the value test

I have tryed this, it gives a blank (empth) string: msg.payload.data.entity_id = env.get('ENT');