# How to use variables in msg path?

**URL:** <https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289>\
**Category:** General\
**Created:** [27 September 2022 11:20 UTC](https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289 "2022-09-27T11:20:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Purize](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/purize/32/68324_2.png) [@Purize](https://discourse.nodered.org/u/Purize)\
**Post date:** [27 September 2022 11:20 UTC](https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289/1 "2022-09-27T11:20:22Z")

</div>

Hi, I'm having problems with this "easy" task, please help.

**Tasks:**

1. Lookup value of "msg.data.game\_id" in "msg.data.games"
2. Copy the attribute "media\_image\_url" to "msg.data.game\_image"

Is the change node able to perform this?

_I'm happy to share the code, but not sure it's needed here._

 ![Screenshot 2022-09-27 at 12.39.40](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/dbbc0df4a1a5409d631b233a620c85e025a05c95.png)

---

<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:** [27 September 2022 11:26 UTC](https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289/2 "2022-09-27T11:26:41Z")

</div>

Use square brackets. Also I think you need the full path (e.g. `msg.aaaa[msg.xxxxx.yyyyy].bbbb`)

What does the built in help say?

---

<div class="post-metadata">

**Author:** ![Purize](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/purize/32/68324_2.png) [@Purize](https://discourse.nodered.org/u/Purize)\
**Post date:** [27 September 2022 11:29 UTC](https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289/3 "2022-09-27T11:29:56Z")

</div>

Thank you!

Working Path:

```auto
data.games[msg.data.game_id].media_image_url

```

---

<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:** [11 October 2022 11:30 UTC](https://discourse.nodered.org/t/how-to-use-variables-in-msg-path/68289/4 "2022-10-11T11:30:08Z")

</div>

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