Serving values formed in the oneditsafe of html file as a variable for the flow

Hello everyone,

A while ago, I was developing a node as described in this thread, to which I cannot post anymore as it was inactive for >60 days.

I got to the point where the base functionality I want to achieve is there, i.e., getting a list from a remote HTTP call, making the list entries become the selectable options in the node, and then have the selections stored when the selection is confirmed:

<script type="text/javascript">
    RED.nodes.registerType('json-mqtt-ex1',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""}
        },
        inputs:1,
        outputs:1,
        icon: "file.png",
        oneditprepare: function() {
            const url = 'https://casatest.free.beeceptor.com/tags'
            let tags = [];
            let selections = [];
            $.ajax({
                url: url,
                type: "GET",
                success: function(result){
                    tags = result.tags
                    console.log(tags)
                    for (let i = 0; i < tags.length; i++){
                        let obj = {value: tags[i], label: tags[i]}
                        selections.push(obj)
                    }
                    $("#node-input-tags").typedInput({type:"tags", types:[{
                        value: "tags",
                        multiple: true,
                        options: selections
                    }]})
                },
                error: function(result){
                    console.log('Error ${error}')
                }
            })

        },
        oneditsave: function() {
            var value = $(".input").typedInput('value');
            console.log(value)
        },
        label: function() {
            return this.name||"json-mqtt-ex1";
        }
    });
</script>

<script type="text/html" data-template-name="json-mqtt-ex1">
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> Tags</label>
        <input type="text" id="node-input-tags">
    </div>
</script>

<script type="text/html" data-help-name="json-mqtt-ex1">
    <p>A node that helps you selecting subscription tags</p>
</script>

This of course does only log the output. I would like to have that output available outside of the node, but I'm not really getting how to do it. I have read plenty of documentation that refers to the different type of variables (node, flow, global), but that does seem to apply to the function (js file) part only, while here I'm working exclusively on the html since I needed to build on the menu.

I hope my explanation is clear!

Thanks and BR,
Gianni

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