0 input and not go to the next node

Hello,
I want to create a function with 0 input and 1 output. I've done the HTML code and the JS code, the code runs fine but does not go to the next node.
Can you help me solve my problem

HTML


<!-- *************** FONCTION test MAIL *************** -->
<script type="text/javascript">
  RED.nodes.registerType('ews-monTest', {
    category: 'EWS',
    color: '#2684ff',
    defaults: {
      name: {
        value: ""
      }
    },  
    inputs: 0,
    outputs: 1,
    icon: "ews-icon.png",
    label: function() {
      return this.name || "ews-monTest";
    }
  });
</script>
<script type="text/x-red" data-template-name="ews-monTest">
  <div class="form-row">
    <label for="node-input-name"><i class="icon-tag"></i> Name</label>
    <input type="text" id="node-input-name" placeholder="Name"/>
  </div>
</script>

<script type="text/x-red" data-help-name="ews-monTest">
    <p>Mon test</p>
</script>

JS

module.exports = function(RED) {
    "use strict";

    /************************************************************************************
    * ewsMonTest
    ************************************************************************************/
    function ewsMonTest(config) {
        console.log("ewsMonTest => ---------------- TEST -------------------");
        RED.nodes.createNode(this,config);
        var node = this;
           var msg = {"payload":"bla"}
           node.send(msg);
           node.send(msg);
        
    }
         	RED.nodes.registerType("ews-monTest", ewsMonTest);
}

RESULT

14 Sep 13:54:11 - [info] Starting flows
ewsMonTest => ---------------- TEST -------------------
14 Sep 13:54:12 - [info] Started flows

cordially

That looks like it should send two msg... but... it will do so as soon as the node is created - which may well be before any other nodes are up and ready to listen to it.

1 Like

I changed my code and it's OK

function ewsMonTest(config) {   
        console.log("ewsMonTest => ---------------- TEST -------------------");
        RED.nodes.createNode(this,config);
        var node = this;
        var msg = {"payload":"bla"}

        setTimeout(function(){ 
            console.log("ewsMonTest => send");
            node.send(msg); 
        }, 5000);          
        
    }

I am going to re-test with my complete notification handling code and I hope it will work. thank you so much

how can we make the code run only when the flow is started ?

You already are. ? The flow is running. Or do you mean something else....

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