# JSONata use sequence index

**URL:** <https://discourse.nodered.org/t/jsonata-use-sequence-index/98141>\
**Category:** General\
**Tags:** jsonata\
**Created:** [15 July 2025 06:50 UTC](https://discourse.nodered.org/t/jsonata-use-sequence-index/98141 "2025-07-15T06:50:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![L4RS](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@L4RS](https://discourse.nodered.org/u/L4RS)\
**Post date:** [15 July 2025 06:50 UTC](https://discourse.nodered.org/t/jsonata-use-sequence-index/98141/1 "2025-07-15T06:50:57Z")

</div>

Hello everbody,

i have a number messages which are the result of a split node. I want to use the parts.index property of this messages to set the message topics. I try to do it by a change node with the follwing JSONata code:

```auto
"/dio/" & $string($flowContext("Pins")[0][(parts.index)]) & "/value"

```

The flow variable `Pins` looks like:

```auto
Pins = [
   [11,12,13,14],
   [21,22,23,24]
]

```

If I replace `(parts.index)` with an number it works (I get the correct topic with the pin nummer looked up in `Pins`). If set the JSONata to `parts.index` only, it works, too (I get the split index as topic). But if put it together, it doesn't work. What did I miss.

Thanks for any suggestions.  
L4rs

---

<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:** [15 July 2025 07:08 UTC](https://discourse.nodered.org/t/jsonata-use-sequence-index/98141/2 "2025-07-15T07:08:40Z")

</div>

Please post what results you want from the sample input you showed.  
Also post a sample flow that injects sample values into the flow context.

---

<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:** [15 July 2025 07:22 UTC](https://discourse.nodered.org/t/jsonata-use-sequence-index/98141/3 "2025-07-15T07:22:37Z")

</div>

Here is another example of why you should tell JSONata which context you are using.

Always use $.property (current context eg in loop) or $$.property (base context eg msg)  
try

```auto
/dio/" & $string($flowContext("Pins")[0][($$.parts.index)]) & "/value"

```

---

<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:** [29 July 2025 07:23 UTC](https://discourse.nodered.org/t/jsonata-use-sequence-index/98141/4 "2025-07-29T07:23:02Z")

</div>

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