# How to modify payload and display it in a text box

**URL:** <https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228>\
**Category:** General\
**Created:** [15 June 2023 14:02 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228 "2023-06-15T14:02:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmystique](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rmystique/32/84365_2.png) [@rmystique](https://discourse.nodered.org/u/rmystique)\
**Post date:** [15 June 2023 14:02 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228/1 "2023-06-15T14:02:06Z")

</div>

I have:  
rpi-dht11 : msg : Object  
{ topic: "rpi-dht11", \_msgid: "d5bb2441c0209e4e", payload: "19.00", humidity: "59.00", isValid: true … }  
and I want to multiply the "payload" by 1.8 +32 to convert it to F degrees and have it show up in my text box on the dashboard? How do I do that, I'm guessing with a function node.

---

<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 June 2023 14:15 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228/2 "2023-06-15T14:15:35Z")

</div>

In a change node  
set `msg.` `payload`  
to the value of `J:``$number($$.payload) * 1.8 - 32`  
and format in ui-text node in value format field  
`{{msg.payload | number : 1}} F` the 1 means 1 decimal place

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 June 2023 14:16 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228/3 "2023-06-15T14:16:54Z")

</div>

You could do it in a `function` node or a `change` node using jsonata. Here are two examples:

Using a change node:

```auto
[{"id":"efb89ae2bffa24b9","type":"inject","z":"ca32d36138412574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19.00","payloadType":"num","x":130,"y":160,"wires":[["26e15a95b49229d8"]]},{"id":"1d45869a320d7e8c","type":"debug","z":"ca32d36138412574","name":"debug 356","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":160,"wires":[]},{"id":"26e15a95b49229d8","type":"change","z":"ca32d36138412574","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(payload * 1.8)+32","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":160,"wires":[["1d45869a320d7e8c"]]}]

```

using a function node:

```auto
[{"id":"d17982a23a425dc1","type":"function","z":"ca32d36138412574","name":"function 1","func":"msg.payload = (msg.payload*1.8) +32\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":220,"wires":[["71aa63bd90d53b81"]]},{"id":"71aa63bd90d53b81","type":"debug","z":"ca32d36138412574","name":"debug 357","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":220,"wires":[]},{"id":"bec56ca9baeffdbe","type":"inject","z":"ca32d36138412574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19.00","payloadType":"num","x":130,"y":220,"wires":[["d17982a23a425dc1"]]}]

```

---

<div class="post-metadata">

**Author:** ![rmystique](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rmystique/32/84365_2.png) [@rmystique](https://discourse.nodered.org/u/rmystique)\
**Post date:** [16 June 2023 01:57 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228/4 "2023-06-16T01:57:06Z")

</div>

> [@zenofmud](#):
>
> `[{"id":"d17982a23a425dc1","type":"function","z":"ca32d36138412574","name":"function 1","func":"msg.payload = (msg.payload*1.8) +32\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":220,"wires":[["71aa63bd90d53b81"]]},{"id":"71aa63bd90d53b81","type":"debug","z":"ca32d36138412574","name":"debug 357","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":220,"wires":[]},{"id":"bec56ca9baeffdbe","type":"inject","z":"ca32d36138412574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19.00","payloadType":"num","x":130,"y":220,"wires":[["d17982a23a425dc1"]]}]`

The function worked great, thank you

---

<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:** [30 June 2023 01:57 UTC](https://discourse.nodered.org/t/how-to-modify-payload-and-display-it-in-a-text-box/79228/5 "2023-06-30T01:57:33Z")

</div>

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