# Function with multiple output combined with node-red-contrib-boolean-logic

**URL:** <https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059>\
**Category:** General\
**Created:** [30 January 2021 17:05 UTC](https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059 "2021-01-30T17:05:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lindi](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@lindi](https://discourse.nodered.org/u/lindi)\
**Post date:** [30 January 2021 17:05 UTC](https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059/1 "2021-01-30T17:05:44Z")

</div>

Hi, I try to use a function with multiple outputs and combine this logic with the “node-red-contrib-boolean-logic”. As long as I use only one output this combination works fine. As soon as I try to use multiple output the Boolean logic elements does not work as expected. Based on the debug messages I get the expected Boolean outputs. Any idea what is wrong in my logic?

My flow extract:

```auto
[{"id":"4bef83eb.56ac0c","type":"debug","z":"58a87a42.fba714","name":"Out1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":1560,"wires":[]},{"id":"59d8d229.4263f4","type":"BDebug","z":"58a87a42.fba714","name":"Debug","x":630,"y":1800,"wires":[]},{"id":"b2052a1c.bfd828","type":"BDebug","z":"58a87a42.fba714","name":"Debug","x":630,"y":1500,"wires":[]},{"id":"c88524d0.06f258","type":"function","z":"58a87a42.fba714","name":"Hysteresis","func":"var testTrue = {payload:true};\nvar testFalse = {payload:false};\n\n\nreturn [testTrue, testFalse];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":390,"y":1640,"wires":[["b2052a1c.bfd828","4bef83eb.56ac0c","b2a4ea6a.086778"],["59d8d229.4263f4","1e4aef66.577d89","b2a4ea6a.086778"]]},{"id":"1e4aef66.577d89","type":"debug","z":"58a87a42.fba714","name":"Out2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":1740,"wires":[]},{"id":"b2a4ea6a.086778","type":"BooleanLogic","z":"58a87a42.fba714","name":"","operation":"OR","inputCount":"2","topic":"result","x":630,"y":1640,"wires":[[]]},{"id":"d38d5c2a.566a08","type":"inject","z":"58a87a42.fba714","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":1640,"wires":[["c88524d0.06f258"]]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 January 2021 21:03 UTC](https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059/2 "2021-01-30T21:03:48Z")

</div>

As described in the help text the boolean node uses message topics to identify the values to be ORd together. You need to specify different topics for the messages coming in on the two paths. So if, in your function you put

```auto
var testTrue = {topic: "A", payload:true};
var testFalse = {topic: "B", payload:false};
return [testTrue, testFalse];

```

then it should work.

---

<div class="post-metadata">

**Author:** ![lindi](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@lindi](https://discourse.nodered.org/u/lindi)\
**Post date:** [31 January 2021 11:22 UTC](https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059/3 "2021-01-31T11:22:17Z")

</div>

@Coline: That’s it, it works know perfect.  
Thank you for your fast response!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 February 2021 11:23 UTC](https://discourse.nodered.org/t/function-with-multiple-output-combined-with-node-red-contrib-boolean-logic/40059/4 "2021-02-14T11:23:08Z")

</div>

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