# $flowContext with req.params?

**URL:** <https://discourse.nodered.org/t/flowcontext-with-req-params/81395>\
**Category:** General\
**Tags:** jsonata\
**Created:** [17 September 2023 10:14 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395 "2023-09-17T10:14:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 September 2023 10:14 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395/1 "2023-09-17T10:14:11Z")

</div>

I have a flow context object called `testobject`:

```auto
{
 test1:[{some content..}],
 test2:[{some other content..}]
}

```

I want to use a change node to return the property that was requested via `req.params.item`

`req.params.item = 'test1'`

In jsonata, I would think the following:  
`$flowContext("testobject")[req.params.item]`

but this does not return anything, what am I missing ?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 September 2023 10:43 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395/2 "2023-09-17T10:43:59Z")

</div>

I'm not a jsonata fan (or regular user of it) but I am not sure property access via square brackets is supported?

Try

```auto
$lookup($flowContext("testobject"), req.params.item)

```

Far easier in function node (as I am certain you know)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 September 2023 10:46 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395/3 "2023-09-17T10:46:48Z")

</div>

You might also be able to simply chose `flow` (instead of jsonata) and enter `testobject[msg.req.params.item]` in the field.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 September 2023 10:51 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395/4 "2023-09-17T10:51:27Z")

</div>

> You might also be able to simply chose `flow` (instead of jsonata) and enter `testobject[msg.req.params.item]` in the field.

Interesting, I was not aware, very nice indeed. I was complicating things I see.

---

<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:** [1 October 2023 10:51 UTC](https://discourse.nodered.org/t/flowcontext-with-req-params/81395/5 "2023-10-01T10:51:28Z")

</div>

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