# And function problem

**URL:** <https://discourse.nodered.org/t/and-function-problem/88842>\
**Category:** General\
**Created:** [21 June 2024 14:43 UTC](https://discourse.nodered.org/t/and-function-problem/88842 "2024-06-21T14:43:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marv](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@Marv](https://discourse.nodered.org/u/Marv)\
**Post date:** [21 June 2024 14:43 UTC](https://discourse.nodered.org/t/and-function-problem/88842/1 "2024-06-21T14:43:37Z")

</div>

I have a problem-i do node red just as a hobby but i need help with the switch

I have made a function -if \< 90 =true  
Else if \> 90 false-that works but this function is connectet with an and block- an the switch which is the other input doesnt work it is alwaystrue

1Picture- Button simulates worth over 90 and the Switch is on =true  
2Picture- Switch is Off -Received invalid topic  
3Picture -Switch is Off Button simulates worth over 90 =True  
And i dont know why the „and“ Block doesnt turns off if the Switch says false

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2fd8575b4b59817765bdd08228c934b4ac2a7ae3.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35596ce89c02ceeaa12b15a1027d2e4fb1ac02c7.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/32721e3354ca40aaf0887bea889c7077fa97cf7f.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [21 June 2024 15:15 UTC](https://discourse.nodered.org/t/and-function-problem/88842/2 "2024-06-21T15:15:19Z")

</div>

I think that you need to have a valid but different msg.topic from the function node and the switch node.

So your switch needs to setup something like this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/edf0ece818baa87f1baa0ef709ce9532247468db.png)

and the function needs to set msg.topic too, eg

```auto
msg.topic = "function"

```

---

<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:** [19 September 2024 15:16 UTC](https://discourse.nodered.org/t/and-function-problem/88842/3 "2024-09-19T15:16:12Z")

</div>

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