# Switch node jsonata predicate match

**URL:** <https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290>\
**Category:** General\
**Tags:** switch-node, jsonata\
**Created:** [23 October 2023 16:05 UTC](https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290 "2023-10-23T16:05:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 October 2023 16:55 UTC](https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290/3 "2023-10-23T16:55:33Z")

</div>

You really should tell JSOnata which scope context to look in, as in `[]` you are in $ scope context local loop. But payload is not in that context it is in Base scope context $$  
That is why i always add the context, people think I am crazy, but if you had you would of come up with

```auto
$$.roominfo.dimmers[$.device_ieee = $$.payload.event.device_ieee].type

```

which would have worked straight off

Notice i let JSONata know where it should be looking, even if it is not required.  
Looking at expression you can see where in scope context things are.

It will save you a lot of head scratching in the future.

---

_[View the full topic](https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290)._
