# Problem with global json object variable and JSONata switch decision

**URL:** <https://discourse.nodered.org/t/problem-with-global-json-object-variable-and-jsonata-switch-decision/27361>\
**Category:** General\
**Created:** [27 May 2020 08:07 UTC](https://discourse.nodered.org/t/problem-with-global-json-object-variable-and-jsonata-switch-decision/27361 "2020-05-27T08:07:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 May 2020 09:47 UTC](https://discourse.nodered.org/t/problem-with-global-json-object-variable-and-jsonata-switch-decision/27361/4 "2020-05-27T09:47:49Z")

</div>

Hi @ljpaff

the JSONata expression option in the Switch node is evaluated against the message it receives - regardless of what you set in the top 'property' box. This means you cannot point it at a context value and evaluate an expression against it. That is slightly surprising to me - I would have expected the JSONata expression to be evaluated against whatever you set in the top property box... I'll have a look to see if we can correct that - although would need to be careful not to change behaviour that people may rely on.

For your scenario, it doesn't matter what you put in the `property` box, but you can use the following expression:

```auto
$globalContext('presencia.abraham') = 'Casa' or $globalContext('presencia.hellem') = 'Casa'

```

- the single `=` is correct for a JSONata expression
- your value is stored under the context name of `presencia` - so you need to include that in the key passed to `$globalContext`

---

_[View the full topic](https://discourse.nodered.org/t/problem-with-global-json-object-variable-and-jsonata-switch-decision/27361)._
