Creating a new node: how do I access the attributes?

Hello,

I'm starting in the creation of nodes for Node-RED. I'd like to create a "simple" node that will take several parameters in its configuration window, and return a concatenation of these parameters...

I was able to create the different HTML fields. My problem is the following: in the javascript file, I can only retrieve the "name" attribute. I also have a "topic" attribute with a corresponding HTML input field, but I can't retrieve the value of this field in my javascript code.

Why does it work with the "name" field by doing
#var msg = {payload:node.name}

but it doesn't work by going:
#var msg = {payload:node.topic}

My HTML file with the 2 input name and topic :

My javascript file where I can get the "name" attribute but not the "topic" attribute :
(if I replace node.name => node.topic : the output show : " " )

I hope my question is clear enough. Thank you in advance for your help.

The confguration data is in the config variable not this. Typically, you assign the fields to this.

I try to keep best practices documented in my jktest node and you can see how to assign the config fields to the node/this object here:

1 Like

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