# Message property set syntax

**URL:** https://discourse.nodered.org/t/message-property-set-syntax/8997
**Category:** General
**Created:** [14 March 2019 19:45 UTC](https://discourse.nodered.org/t/message-property-set-syntax/8997 "2019-03-14T19:45:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![darabontors](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@darabontors](https://discourse.nodered.org/u/darabontors)
#### Post date: [14 March 2019 19:45 UTC](https://discourse.nodered.org/t/message-property-set-syntax/8997/1 "2019-03-14T19:45:04Z")

</div>

Hi everyone,  
I am pretty new to Node Red and JavaScript in general. I have a question about setting a property of a message. I have the following code snippet:

var uisource = flow.get("source");  
output.push([datetime, msg.payload[i][j].uisource]);

I can't figure out the syntax to put the value of the "uisource" string variable to msg.payload[i][j].\*\*\*\*\* So for example, if I var uisource = "temperature", my second line looks like:  
output.push([datetime, msg.payload[i][j].temperature]);

If uisource = "light", then:  
output.push([datetime, msg.payload[i][j].light]);

I need the variable uisource to change dinamically and also the identifier of the property I want to access.

Sorry if it is a very amateur question.  
Thank you in advance for any help.  
Örs

---

<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: [14 March 2019 20:08 UTC](https://discourse.nodered.org/t/message-property-set-syntax/8997/2 "2019-03-14T20:08:24Z")

</div>

Hi @darabontors

> [@darabontors](#):
>
> Sorry if it is a very amateur question.

No problem - everyone has to learn this the first time 🙂

You need to use what is called '[bracket notation](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics#Bracket_notation)'.

In fact, your code already does it with the way it uses `i` and `j` to reference parts of the message payload... you just need to extend that for `uisource` as well.

So if `uisource` is set to the name of the property you want to use, you would do:

```auto
msg.payload[i][j][uisource]

```

---

<div class="post-metadata">

### Author: ![darabontors](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@darabontors](https://discourse.nodered.org/u/darabontors)
#### Post date: [15 March 2019 03:48 UTC](https://discourse.nodered.org/t/message-property-set-syntax/8997/3 "2019-03-15T03:48:13Z")

</div>

Hi Nick,  
Wow. That worked like a charm.  
Thank you so much!  
Have a great day!  
Örs
