# Using boolean status from context

**URL:** <https://discourse.nodered.org/t/using-boolean-status-from-context/78306>\
**Category:** General\
**Created:** [9 May 2023 20:40 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306 "2023-05-09T20:40:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abandonedhandrail](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@abandonedhandrail](https://discourse.nodered.org/u/abandonedhandrail)\
**Post date:** [9 May 2023 20:40 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/1 "2023-05-09T20:40:23Z")

</div>

Evening all,

I'm tring to find a way to use true/false status of an object stored in context to drive some later code. I'm hoping to read multiple values (and booleans) from context into multiple payloads, and have multiple outputs from a single function. The Int values I read from Context are coming out as expected, but booleans are undefined ☹

Is there a simple way of getting a true/false output from a function node?  
My flow is large, so here's just the principle I'm using to no avail:

```auto
return [

    { payload: flow.get('mbValues.Alarm_b8.value') }

    ]
    
;

```

---

<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:** [9 May 2023 21:02 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/2 "2023-05-09T21:02:49Z")

</div>

That should work.  
Check in the Context pane in the editor what is actually in that field.  
Post a screenshot showing it if you think it is correct.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 May 2023 21:31 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/3 "2023-05-09T21:31:40Z")

</div>

As context stores are often file or database based, I'm not sure if booleans get returned as booleans - they may come back as strings.

---

<div class="post-metadata">

**Author:** ![abandonedhandrail](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@abandonedhandrail](https://discourse.nodered.org/u/abandonedhandrail)\
**Post date:** [9 May 2023 22:14 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/5 "2023-05-09T22:14:21Z")

</div>

How strange... payload: flow.get('mbValues.Alarm\_b8.value') did not work, but I tried copying the path directly from the Context pane and payload: flow.get('mbValues["Alarm\_b8"].value') does...

The Ints appear to work whichever way I call up the object values... so should I be referencing all values from context in this latter way, or just boolean values?

---

<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:** [10 May 2023 08:49 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/6 "2023-05-10T08:49:34Z")

</div>

Could you copy/paste the code that works and the code that doesn't please?  
Check it still doesn't work before posting. Maybe put both lines of code in, with one commented out for each test.

---

<div class="post-metadata">

**Author:** ![abandonedhandrail](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@abandonedhandrail](https://discourse.nodered.org/u/abandonedhandrail)\
**Post date:** [10 May 2023 11:06 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/7 "2023-05-10T11:06:57Z")

</div>

Hi Colin, sure...

This works:

```auto
return [

    { payload: flow.get('mbValues["StateMachine_u16"].value') },

    ]
    
;

```

This still doesn't work:

```auto
return [

    { payload: flow.get('mbValues.StateMachine_u16.value') },

    ]
    
;

```

---

<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:** [10 May 2023 11:20 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/8 "2023-05-10T11:20:41Z")

</div>

How are you writing the data to context?

---

<div class="post-metadata">

**Author:** ![abandonedhandrail](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@abandonedhandrail](https://discourse.nodered.org/u/abandonedhandrail)\
**Post date:** [10 May 2023 12:28 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/9 "2023-05-10T12:28:35Z")

</div>

I'm capturing modbus data after a buffer parse, like so

```auto
// update mbValues
flow.set(`mbValues.${msg.topic}`, { ...flow.get(`mbValues.${msg.topic}`), ...msg.payload })

```

---

<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:** [9 July 2023 12:29 UTC](https://discourse.nodered.org/t/using-boolean-status-from-context/78306/10 "2023-07-09T12:29:04Z")

</div>

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