How can I create a default property like array?


I try to set an array var to store some objects in a node, something like that:

In the image, Atributos is an array with 3 objects, but I can't use this variable in the js file.


That is not one of the core nodes I recognise. Which node is that ?
As it's not a core node you may need to contact the author of the node directly and ask them to add to their docs.

It's a custom node that I'm developing. It's a node that create an entity in Orion Context Broker, and I need an array with the attributes of the entity.


Ah.. - you will need to build the array into a default property during the oneditsave function and pass it back that way (and vice versa you will need to take the saved version from that property and re-populate the ui during oneditprepare

Are oneditsave and oneditprepare functions for js file? I try it, but I have the info in the form and it isn't accessible for js file.


they are javascript functions in the html file - see the docs - Once you have manipulated them into a property defined in the defaults list (eg a hidden field node-input-myArray as myArray in the defaults list), then they will be available in the config on the js side.

Ok, I can define in the defaults like that?:

defaults: {
myArray: { value: new Array()}

I would go for myArray: { value: [] }

I try something like that

RED.nodes.registerType('fiware-in', {
        category: 'Fiware',
        color: '#a6bbcf',
            name: {value:""},
            fiware_action: {value:"", require:true},
            fiware_host: {value:"", requite:true},
            fiware_entity: {value:"", require:true},
            fiware_attrs_array: {value:[]},
            fiware_options_json: {value:"", require:true}

And then, in the html:

<div class="form-attr">
            <label for="node-input-fiware_attrs_array"><i class="icon-tag"></i> Atributos </label>
            <input type="text" id="attr_name_1" placeholder="Name">
            <input type="text" id="attr_type_1" placeholder="Type">
            <input type="text" id="attr_value_1" placeholder="Value">
            <div id="addAttr" class="form-row"></div>
            <input type="button" name="button_add" value="Añadir atributo" onclick="addAttr()">
            <input type="button" name="button_remove" value="Borrar último atributo" onclick="removeAttr()">
            <input type="button" name="button_validate" value="Validar atributos" onclick="validate()">

The validate button, copy an array with each attribute in fiware_attrs_array. But when I try to receive those data in the js file, I have an empty array