Overriding the Delay-Node default delay from a function

Using a Delay-Node configured to override delay; I've tried this code in a Function-Node:

var delayTime = 20000; // 20 seconds
var msgDelay = { payload: "START", timerDuration: delayTime, timerDurationUnit: "milliseconds" };
return msgDelay;

It fails to override the 5 second default. Is there a way to send a message to the Delay-Node from a function node that overrides the default 5 second delay, and simultaneously triggers the delay?

Have you tried sending delay rather than timerDuration.
As stated in help text

Inputs

delay [number]
Sets the delay, in milliseconds, to be applied to the message. This option only applies if the node is configured to allow the message to override the configured default delay interval.

You need to set msg.delay. Or in your case msgDelay.delay, not msgDelay.timerDuration.

And the override time is always in milliseconds, timerDurationUnit has no impact.

Will just setting msgDelay.delay = 20000 alone cause an override and trigger, or do I need to send a second message to trigger?

Got it; this works:

var delayTime = 20000; // 20 seconds
var msgDelay = { payload: "START", delay: delayTime};
return msgDelay;

X

The arrival of any message at the delay node will start the timer, regardless of the value of msg.payload.
After 20 seconds, the complete message object {payload:"START", delay: 20000} is passed on from the delay node

You're correct; I removed the payload and it still works. I thought that should be the case, but every thing I tried failed. I just wasn't specifying the 'delay' property correctly; the documentation msg.delay is misleading.

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