# Change a value in a message object

**URL:** <https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304>\
**Category:** General\
**Created:** [17 June 2021 15:15 UTC](https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304 "2021-06-17T15:15:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![descoward](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@descoward](https://discourse.nodered.org/u/descoward)\
**Post date:** [17 June 2021 15:15 UTC](https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304/1 "2021-06-17T15:15:15Z")

</div>

Hi

I have the following function as part of my weather station dashboard-

var m = {  
"series": ["Rainfall"],  
"data":[msg.payload[0] ["sum(RAINFALL)"]],  
"labels":["Todays Rainfall"]  
};  
return {payload:[m]};

Long story short the data is rainfall sum from my database and is in inches. I've been running it this way for 3 years. I wish now to modify it to mm (\*25.4) before returning the message to my chart. Could somebody please explain how I can do this inside of this function.

This is how the data appears when returned:

[{"series":["Rainfall"],"data":[0.293],"labels":["Todays Rainfall"]}]

Thanks  
Derek

---

<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 June 2021 15:18 UTC](https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304/2 "2021-06-17T15:18:38Z")

</div>

> [@descoward](#):
>
> I wish now to modify it to mm (\*25.4) before returning the message to my chart. Could somebody please explain how I can do this inside of this function.

```auto
var m = {
  "series": ["Rainfall"],
  "data": [msg.payload[0]["sum(RAINFALL)"] * 25.4],
  "labels": ["Todays Rainfall"]
};
return {payload:[m]};

```

---

<div class="post-metadata">

**Author:** ![descoward](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@descoward](https://discourse.nodered.org/u/descoward)\
**Post date:** [17 June 2021 18:32 UTC](https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304/3 "2021-06-17T18:32:48Z")

</div>

Thanks Steve. I gave up trying to put it in the right place!

Thanks for your help.  
Derek

---

<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 July 2021 18:33 UTC](https://discourse.nodered.org/t/change-a-value-in-a-message-object/47304/4 "2021-07-01T18:33:45Z")

</div>

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