# Can I return a real null value to a multi out function from an else if statement?

**URL:** <https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852>\
**Category:** General\
**Created:** [23 January 2024 23:21 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852 "2024-01-23T23:21:58Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 January 2024 01:15 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/21 "2024-01-24T01:15:44Z")

</div>

Mistakes are allowed.

Everyone makes then and they are part of learning. I can vouch for that. 😉

```auto
else {
    ""
};

```

Is also a problem.

I think it should be something like:

```auto
else {
   msg1.payload = "";
};
return msg1;

```

But not sure.

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [24 January 2024 03:29 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/22 "2024-01-24T03:29:51Z")

</div>

Ok I cleaned things up but I still have a problem with using the or statement.

I labeled the conditions and included json that should pass and what rule they should be filtered by. Also one that should return null.

Right now it is as follows.

JSON for Rule 1 passes through rule 1,  
JSON for Rule 2 passes through rule 2,  
this is where the problem is:  
JSON for Rule 3 passes through rule 2  
JSON for null passes through rule 2

```auto

let msg1 = {};
// rule 1
if (evco === "CrossRegionDetection" && action === "Start" && ivsRule === "ivs")
    
msg1.payload = {"domain": haDom,"service": serv, "data": {"entity_id": cameraEntity},
    "driveFolder": "single",
    "title": cameraName,};
// rule 2
else if (evco === "CrossRegionDetection" && action === "Start" && ivsRule === "first" || "garden" || "alley" || "basement")

msg1.payload = {"domain": haDom, "service": serv, "data": {"entity_id": cameraEntity},
    "driveFolder": "multi",
    "title": ivsRule,};
// rule 3
else if (evco === "VideoMotion" && action === "Start")

msg1.payload = {"domain": haDom,"service": serv, "data": {"entity_id": cameraEntity},
    "driveFolder": "single",
    "title": cameraName,};

else {
msg1 = null
};

let msg2 = null;

return [msg1, msg2]

```

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [24 January 2024 03:52 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/23 "2024-01-24T03:52:27Z")

</div>

I added a rule key to the output so you can see what passes through which rule in the debug.

```auto
[{"id":"492a144664cddd58","type":"debug","z":"60f2d2277843c698","name":"debug 21","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":500,"wires":[]},{"id":"bd06552fad2076d9","type":"debug","z":"60f2d2277843c698","name":"debug 22","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":600,"wires":[]},{"id":"2889b1460434c0d1","type":"inject","z":"60f2d2277843c698","name":"second (rule 1)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"event_type\":\"dahua_event_received\",\"event\":{\"Code\":\"CrossRegionDetection\",\"action\":\"Start\",\"index\":\"3\",\"data\":{\"Action\":\"Appear\",\"Class\":\"Normal\",\"CountInGroup\":1,\"DetectRegion\":[[4168,3111],[4405,7778],[5916,7510],[5388,3160]],\"EventSeq\":26,\"FrameSequence\":2419837,\"GroupID\":0,\"IndexInGroup\":0,\"Mark\":0,\"Name\":\"ivs\",\"Object\":{\"Action\":\"Appear\",\"BoundingBox\":[3752,2840,5112,4664],\"Center\":[4432,3752],\"Confidence\":0,\"FrameSequence\":0,\"ObjectID\":176,\"ObjectType\":\"Unknown\",\"RelativeID\":0,\"Source\":0,\"Speed\":0,\"SpeedTypeInternal\":0},\"PTS\":58592,\"RuleId\":1,\"Sequence\":0,\"Source\":0,\"Track\":null,\"UTC\":1705948123,\"UTCMS\":0},\"name\":\"XVR second floor\",\"DeviceName\":\"XVR second floor\"},\"origin\":\"LOCAL\",\"time_fired\":\"2024-01-22T23:28:45.514691+00:00\",\"context\":{\"id\":\"01HMSR2GEAFBBXNWHDVCK556PJ\",\"parent_id\":null,\"user_id\":null}}","payloadType":"json","x":180,"y":420,"wires":[["e9b06bb2bc44145a"]]},{"id":"bcfc9f4e928bf816","type":"inject","z":"60f2d2277843c698","name":"basement (rule 2)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"event_type\":\"dahua_event_received\",\"event\":{\"Code\":\"CrossRegionDetection\",\"action\":\"Start\",\"index\":\"2\",\"data\":{\"Action\":\"Appear\",\"Class\":\"Normal\",\"CountInGroup\":1,\"DetectRegion\":[[5697,7792],[7827,6965],[7954,6187],[5952,7184]],\"EventSeq\":5,\"FrameSequence\":2418608,\"GroupID\":0,\"IndexInGroup\":0,\"Mark\":0,\"Name\":\"basement\",\"Object\":{\"Action\":\"Appear\",\"BoundingBox\":[6312,6024,6984,7272],\"Center\":[6648,6648],\"Confidence\":0,\"FrameSequence\":0,\"ObjectID\":33,\"ObjectType\":\"Unknown\",\"RelativeID\":0,\"Source\":0,\"Speed\":0,\"SpeedTypeInternal\":0},\"PTS\":37761,\"RuleId\":1,\"Sequence\":0,\"Source\":0,\"Track\":null,\"UTC\":1705948103,\"UTCMS\":0},\"name\":\"XVR first floor\",\"DeviceName\":\"XVR first floor\"},\"origin\":\"LOCAL\",\"time_fired\":\"2024-01-22T23:28:24.743001+00:00\",\"context\":{\"id\":\"01HMSR1W57T75MKGFXS2J1A8GM\",\"parent_id\":null,\"user_id\":null}}","payloadType":"json","x":180,"y":480,"wires":[["e9b06bb2bc44145a"]]},{"id":"6f88ea7e9ba32377","type":"inject","z":"60f2d2277843c698","name":"first (rule 2)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"event_type\":\"dahua_event_received\",\"event\":{\"Code\":\"CrossRegionDetection\",\"action\":\"Start\",\"index\":\"2\",\"data\":{\"Action\":\"Cross\",\"Class\":\"Normal\",\"CountInGroup\":1,\"DetectRegion\":[[2293,6198],[3986,6222],[3568,7972],[2658,8069],[1893,6660],[2293,6344]],\"Direction\":\"Leave\",\"EventSeq\":10,\"FrameSequence\":2419240,\"GroupID\":0,\"IndexInGroup\":0,\"Mark\":0,\"Name\":\"first\",\"Object\":{\"Action\":\"Appear\",\"BoundingBox\":[2944,3864,4992,7960],\"Center\":[3968,5912],\"Confidence\":0,\"FrameSequence\":0,\"ObjectID\":35,\"ObjectType\":\"Unknown\",\"RelativeID\":0,\"Source\":0,\"Speed\":0,\"SpeedTypeInternal\":0},\"PTS\":48461,\"RuleId\":2,\"Sequence\":0,\"Source\":0,\"Track\":null,\"UTC\":1705948113,\"UTCMS\":0},\"name\":\"XVR first floor\",\"DeviceName\":\"XVR first floor\"},\"origin\":\"LOCAL\",\"time_fired\":\"2024-01-22T23:28:35.553034+00:00\",\"context\":{\"id\":\"01HMSR26Q1RR5FPACJ8A30RQES\",\"parent_id\":null,\"user_id\":null}}","payloadType":"json","x":190,"y":540,"wires":[["e9b06bb2bc44145a"]]},{"id":"8bcaf65812a52597","type":"inject","z":"60f2d2277843c698","name":"should return null","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"event_type\":\"dahua_event_received\",\"event\":{\"Code\":\"VideoMotion\",\"action\":\"Stop\",\"index\":\"3\",\"data\":{\"SmartMotionEnable\":false},\"name\":\"XVR second floor\",\"DeviceName\":\"XVR second floor\"},\"origin\":\"LOCAL\",\"time_fired\":\"2024-01-22T23:24:13.969622+00:00\",\"context\":{\"id\":\"01HMSQT78HSZHSW6Y2HY3PXDW6\",\"parent_id\":null,\"user_id\":null}}","payloadType":"json","x":180,"y":660,"wires":[["e9b06bb2bc44145a"]]},{"id":"e9b06bb2bc44145a","type":"function","z":"60f2d2277843c698","name":"camera","func":"// isolate relevant incoming JSON\nlet cameraName = msg.payload.event.DeviceName;\nlet ivsRule = msg.payload.event.data.Name;\nlet evco = msg.payload.event.Code;\nlet action = msg.payload.event.action;\n\n// phone state\nlet phoneState = global.get('homeassistant.homeAssistant.states[\"sensor.pixel_7_phone_state_2\"].state');\n\n\n\n// create entity type for service call\nconst haDom = \"camera\"; // domain\nconst serv = \"snapshot\"; // service\nconst entityType = \"camera.\"; // same as domain with period\n// replace spaces with _ add entity type at begining add _main to end\nlet cameraEntity = entityType + (cameraName.toLowerCase()).replace(/\\s/g, \"_\") + \"_main\";\n\n\nlet msg1 = {};\n// rule 1\nif (evco === \"CrossRegionDetection\" && action === \"Start\" && ivsRule === \"ivs\")\n \nmsg1.payload = {\"domain\": haDom,\"service\": serv, \"data\": {\"entity_id\": cameraEntity},\n \"driveFolder\": \"single\",\n \"title\": cameraName,\n \"rule\": \"one\",};\n// rule 2\nelse if (evco === \"CrossRegionDetection\" && action === \"Start\" && ivsRule === \"first\" || \"garden\" || \"alley\" || \"basement\")\n\nmsg1.payload = {\"domain\": haDom, \"service\": serv, \"data\": {\"entity_id\": cameraEntity},\n \"driveFolder\": \"multi\",\n \"title\": ivsRule,\n \"rule\": \"two\",};\n// rule 3\nelse if (evco === \"VideoMotion\" && action === \"Start\")\n\nmsg1.payload = {\"domain\": haDom,\"service\": serv, \"data\": {\"entity_id\": cameraEntity},\n \"driveFolder\": \"single\",\n \"title\": cameraName,\n \"rule\": \"three\",};\n\nelse {\nmsg1 = null\n};\n\n\n\n\n\n\nlet msg2 = null;\n\n\n\n\n\nreturn [msg1, msg2]","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":560,"wires":[["492a144664cddd58"],["bd06552fad2076d9"]]},{"id":"3796393bc7bed77a","type":"inject","z":"60f2d2277843c698","name":"motion start (rule 3)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"event_type\":\"dahua_event_received\",\"event\":{\"Code\":\"VideoMotion\",\"action\":\"Start\",\"index\":\"15\",\"data\":{\"SmartMotionEnable\":false},\"name\":\"XVR front step\",\"DeviceName\":\"XVR front step\"},\"origin\":\"LOCAL\",\"time_fired\":\"2024-01-22T23:24:13.506340+00:00\",\"context\":{\"id\":\"01HMSQT6T2NSYRJGYGYFVE2K5Q\",\"parent_id\":null,\"user_id\":null}}","payloadType":"json","x":170,"y":600,"wires":[["e9b06bb2bc44145a"]]}]

```

---

<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:** [24 January 2024 08:29 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/24 "2024-01-24T08:29:33Z")

</div>

`if (evco === "CrossRegionDetection" && action === "Start" && ivsRule === "first" || "garden" || "alley" || "basement")`

Since the string "garden" is always considered to be true then the if will always be considered true. Possible you meant this or something similar.  
`if (evco === "CrossRegionDetection" && action === "Start" && (ivsRule === "first" || ivsRule === "garden" || ivsRule === "alley" || ivsRule === "basement"))`

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [24 January 2024 08:49 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/25 "2024-01-24T08:49:04Z")

</div>

That was it. Looking at the mistake I made and the solution, it makes sense to me now. Thank you.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 January 2024 08:55 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/26 "2024-01-24T08:55:06Z")

</div>

> [@mikefila](#):
>
> That was it.

Guessing you did not see my reply hours ago.

> [@Steve-Mcl](#):
>
> Should be
> 
> ```auto
> if (evco === "CrossRegionDetection" && action === "Start" && (ivsRule === "first" || ivsRule === "second" || ivsRule ==="third") )
> 
> ```

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [24 January 2024 08:58 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/27 "2024-01-24T08:58:10Z")

</div>

I did miss that.

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [28 January 2024 01:06 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/28 "2024-01-28T01:06:52Z")

</div>

In an `else if` statement, once there is a match, does it skip the rest of the block? Would a `switch` statement be more appropriate if I wanted it to stop the rest of the block only?

If I understand correctly, adding `break` at the end of a `case` it will jump all remaining blocks of code?

---

<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:** [28 January 2024 08:04 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/29 "2024-01-28T08:04:07Z")

</div>

Your question is not clear, please show a simple code example of what you are trying to do.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 January 2024 08:13 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/30 "2024-01-28T08:13:16Z")

</div>

> [@mikefila](#):
>
> In an `else if` statement, once there is a match, does it skip the rest of the block

Yes. And super easy to test: [if...else - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)

> [@mikefila](#):
>
> If I understand correctly, adding `break` at the end of a `case` it will jump all remaining blocks of code

Yes, however this information is readily available & simple to try out: [switch - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)

* * *

One thing I often point out is: this is a visual flow based development tool & all the things you speak of in this thread can be done using the visual flow paradigm - before learning to code js, perhaps you should learn node-red?

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [28 January 2024 10:03 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/31 "2024-01-28T10:03:52Z")

</div>

> [@Steve-Mcl](#):
>
> perhaps you should learn node-red?

ouch I have been using it for 3 years now. I'm often the on HA's nodered forum explaining how to use jsonata to pass variables and have quite complex flows.

This is my first real venture into the function node. Everything works. I've been trying to minimize as much as I can. Here's the link to the entire function code.

> <https://github.com/Mikefila/HaNr-event-bus-flow/blob/main/camerafunc.js>

And the project

> **[GitHub - Mikefila/HaNr-event-bus-flow: Using node red with home assistant...](https://github.com/Mikefila/HaNr-event-bus-flow)**
>
> Using node red with home assistant event bus. Contribute to Mikefila/HaNr-event-bus-flow development by creating an account on GitHub.

Any comments would be much appreciated.I apologize for the snippets and not the whole code. I was trying to learn my way through it.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 January 2024 10:29 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/32 "2024-01-28T10:29:02Z")

</div>

> [@mikefila](#):
>
> > [@Steve-Mcl](#):
> >
> > perhaps you should learn node-red?
> 
> ouch I have been using it for 3 years now

My apologies. I really do try not to assume but sometimes I slip and I slipped up here. Please forgive me ☺

I hope you appreciate my intent though? That much of what you are doing is possible in a more node-red way. And not for the sake of doing it in a flow manner but because a lot of the nodes were designed to help users struggling with code to do things in a no code/low code manner.

I don't have screen time today but will try to take a look and provide constructive comments.

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [28 January 2024 10:45 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/33 "2024-01-28T10:45:10Z")

</div>

Yeah no definitely, I laughed when I saw that. I'm always reading here, this forum has been instrumental in my progress. I don't post here much because I usually find what I am looking for.

I'd appreciate any advice. I know the message creation is convoluted and some of it's logic statements unnecessary. I was considering changing this block to a 'switch'.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/361a4b1ab5b59fed56b66f1e533cacb0b99cfc25.png)

I just want to make sure it was not continuing if one of the two conditions are met.

---

<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:** [28 January 2024 10:47 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/34 "2024-01-28T10:47:57Z")

</div>

So what exactly do you mean by  
`In an else if statement, once there is a match, does it skip the rest of the block`  
If you mean, with a sequence of if, else if, else if, else statements, once one of the if's is met does it skip the others, then the answer is yes, that is what 'else' means.

The reason your question is ambiguous is that it is not clear what you mean by 'block'. You might have meant whether you can so something like

```auto
if (a) {
  // some code
  break;
  // some more code
} else if ...

```

and were asking if break can be used to break you out of that block.

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [28 January 2024 10:57 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/35 "2024-01-28T10:57:20Z")

</div>

My understanding is that this complete `else if` statement was a code block.

![Screenshot 2024-01-28 055242](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f13eacbe41e2b9d2935fed44bba27ec81b02f8c.jpeg)

If I try to insert a break, it gives me this error

> A 'break' statement can only be used within an enclosing iteration or switch statement.(1105)

![Screenshot 2024-01-28 055201](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5c36fc9fe8d1a2e200a20aa3887023b913d5348c.jpeg)

---

<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:** [28 January 2024 11:16 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/36 "2024-01-28T11:16:09Z")

</div>

> [@mikefila](#):
>
> My understanding is that this complete `else if` statement was a code block.

If you mean the complete `if, else if, else` is a code block then possibly. But so is anything contained in `{ .. }`

Why would you need the break? The `else` already implies that it will only run that if the `if` fails. What else could it mean?

---

<div class="post-metadata">

**Author:** ![mikefila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikefila/32/95223_2.png) [@mikefila](https://discourse.nodered.org/u/mikefila)\
**Post date:** [28 January 2024 11:17 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/37 "2024-01-28T11:17:59Z")

</div>

To explain further `if (aTT < cameraTest)` returns true, it jumps the rest of the block and then reads the next block that starts with `if (att < cameraTest) `

 ![Screenshot 2024-01-28 060933](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/06371cfc68f5409740d8cdabd3c4a8fec6d2469b.jpeg)

In this scenario if `papayas` is true it jumps to the end and sends the message

 ![Screenshot 2024-01-28 061106](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/5416f57c6065ad00b48eaecd5b131cc687b96217.jpeg)

Or does every thing need to be in the switch?

---

<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:** [28 January 2024 11:25 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/38 "2024-01-28T11:25:40Z")

</div>

> [@mikefila](#):
>
> `if (aTT < cameraTest)` returns true, it jumps the rest of the block and then reads the next block that starts with `if (att < cameraTest)`

Yes

> [@mikefila](#):
>
> In this scenario if `papayas` is true it jumps to the end and sends the message

No, the break sends it to the end of the Switch statement.

---

<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:** [11 February 2024 11:26 UTC](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852/39 "2024-02-11T11:26:05Z")

</div>

Closed on 11 February 2024 11:26 UTC

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

[Previous page](https://discourse.nodered.org/t/can-i-return-a-real-null-value-to-a-multi-out-function-from-an-else-if-statement/84852.md?page=1)
