# Translating payload not showing in text box dashboard

**URL:** <https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646>\
**Category:** General\
**Created:** [19 April 2025 09:13 UTC](https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646 "2025-04-19T09:13:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomasvjohansen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomasvjohansen/32/32779_2.png) [@thomasvjohansen](https://discourse.nodered.org/u/thomasvjohansen)\
**Post date:** [19 April 2025 09:13 UTC](https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646/1 "2025-04-19T09:13:32Z")

</div>

Trying to monitor my gardena lawnmower, I have a payload (msg.payload[0].devices[0].services[0].activity.value) with activity text, I want to translate and show in text field but it will not show.  
It gets translated in my debug node but same output not showing up in text box.

in textbox format field: {{msg.payload.aktivitet}}

in debug payload: msg.payload.aktivitet

Here is an example with injected text, function to translate and output to textbox and debug node:

```auto
[{"id":"7d4a1d17f668d0b2","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"6807ae4760fe5dfb","type":"debug","z":"7d4a1d17f668d0b2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.aktivitet","targetType":"msg","statusVal":"payload","statusType":"auto","x":1100,"y":220,"wires":[]},{"id":"243c668763a1618a","type":"ui_text","z":"7d4a1d17f668d0b2","group":"9852e93e7fb4fe70","order":2,"width":"6","height":"2","name":" {{msg.payload.aktivitet}}","label":"","format":"{{msg.payload.aktivitet}}","layout":"row-center","className":"","x":1110,"y":170,"wires":[]},{"id":"037e5f0bfa2a22ed","type":"function","z":"7d4a1d17f668d0b2","name":"","func":"var activity = msg.payload[0].devices[0].services[0].activity.value;\nvar aktivitet;\n\n\nif (activity == \"PAUSED\") { activity = \"Sat på pause\"; }\n\nif (activity == \"OK_CUTTING\") { activity = \"Klipper græs (auto)\"; }\n\nif (activity == \"OK_CUTTING_TIMER_OVERRIDDEN\") { activity = \"Klipper græs (manuelt)\"; }\n\nif (activity == \"OK_SEARCHING\") { activity = \"Søger ladestation\"; }\n\nif (activity == \"OK_CHARGING\") { activity = \"Lader op\"; }\n\nif (activity == \"PARKED_TIMER\") { activity = \"Parkeret indtil næste tidsplan\"; }\n\nif (activity == \"PARKED_PARK_SELECTED\") { activity = \"Parkeret indtil videre, regn?\"; }\n\nif (activity == \"PARKED_AUTOTIMER\") { activity = \"Parkeret græs for lavt\"; }\n\nif (activity == \"NONE\") { activity = \"Fejl?\"; }\n\nmsg.payload.aktivitet = activity;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":200,"wires":[["6807ae4760fe5dfb","243c668763a1618a"]]},{"id":"56282e16915fb7f7","type":"inject","z":"7d4a1d17f668d0b2","name":"","props":[{"p":"payload[0].devices[0].services[0].activity.value","v":"PARKED_PARK_SELECTED","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":730,"y":200,"wires":[["037e5f0bfa2a22ed"]]},{"id":"9852e93e7fb4fe70","type":"ui_group","name":"Mower","tab":"cfc2786282105f1c","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"cfc2786282105f1c","type":"ui_tab","name":"Mower","icon":"mi-grass","order":7,"disabled":false,"hidden":false}]

```

 ![Udklip](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b912fb7eef9417eb7cd1fd5380019d134691491e.png)

---

<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:** [19 April 2025 09:49 UTC](https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646/2 "2025-04-19T09:49:33Z")

</div>

msg.payload is an array [0].  
you can not add an object property to the payload if it is an array.  
You would first need to turn msg.payload into an object `msg.payload = {}`

p.s here is a alternative way rather than all the if statements, you can create a lookup object.

```auto
let activity = msg.payload[0].devices[0].services[0].activity.value;
//create lookup object
const translate = {
    "PAUSED": "Sat på pause",
    "OK_CUTTING": "Klipper græs (auto)"
    //add more translations here
}
if (Object.keys(translate).includes(activity)){
    msg.payload = {aktivitet: translate[activity]}; // if activity, translate and make payload an object
}else {
    msg = null; // return null if no activity in lookup
}
return msg;

```

Untested may contain typo's

---

<div class="post-metadata">

**Author:** ![thomasvjohansen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomasvjohansen/32/32779_2.png) [@thomasvjohansen](https://discourse.nodered.org/u/thomasvjohansen)\
**Post date:** [19 April 2025 10:57 UTC](https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646/3 "2025-04-19T10:57:34Z")

</div>

> [@E1cid](#):
>
> ```auto
> et activity = msg.payload[0].devices[0].services[0].activity.value;
> //create lookup object
> const translate = {
> "PAUSED": "Sat på pause",
> "OK_CUTTING": "Klipper græs (auto)"
> //add more translations here
> }
> if (Object.keys(translate).includes(activity)){
> msg.payload = {aktivitet: translate[activity]}; // if activity, translate and make payload an object
> }else {
> msg = null; // return null if no activity in lookup
> }
> return msg;
> 
> ```

Works perfectly, and I learned something new, thanks a lot really helped me.

---

<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:** [3 May 2025 10:58 UTC](https://discourse.nodered.org/t/translating-payload-not-showing-in-text-box-dashboard/96646/4 "2025-05-03T10:58:00Z")

</div>

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