HowTo define and use global utillity function in V3.x and higher

Why do you want a globally defined function?

The visual equivalent is the link-call node.

image

Demo Flow...

[{"id":"e8031839f82a4fac","type":"link in","z":"65b88f90c5129bc8","name":"mult * 10","links":[],"x":255,"y":600,"wires":[["e7680a651c3e6672"]]},{"id":"9f01e7a2880c059b","type":"link out","z":"65b88f90c5129bc8","name":"link out 1","mode":"return","links":[],"x":465,"y":600,"wires":[]},{"id":"e7680a651c3e6672","type":"function","z":"65b88f90c5129bc8","name":"mult * 10","func":"msg.payload = msg.payload * 10\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":600,"wires":[["9f01e7a2880c059b"]]},{"id":"342498501c490f97","type":"inject","z":"65b88f90c5129bc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":180,"y":480,"wires":[["29aa1920221cce50"]]},{"id":"29aa1920221cce50","type":"link call","z":"65b88f90c5129bc8","name":"","links":["e8031839f82a4fac"],"linkType":"static","timeout":"30","x":340,"y":480,"wires":[["cea61592b52d6752"]]},{"id":"cea61592b52d6752","type":"debug","z":"65b88f90c5129bc8","name":"expect 20","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":480,"wires":[]},{"id":"967c68d72db42af5","type":"link call","z":"65b88f90c5129bc8","name":"","links":["e8031839f82a4fac"],"linkType":"static","timeout":"30","x":340,"y":520,"wires":[["1153c860b9b37a59"]]},{"id":"fe1d85d82704835b","type":"inject","z":"65b88f90c5129bc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":180,"y":520,"wires":[["967c68d72db42af5"]]},{"id":"1153c860b9b37a59","type":"debug","z":"65b88f90c5129bc8","name":"expect 40","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":520,"wires":[]}]
2 Likes