# Function node, payload change text

**URL:** https://discourse.nodered.org/t/function-node-payload-change-text/47337
**Category:** General
**Created:** [18 June 2021 14:32 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337 "2021-06-18T14:32:18Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)
#### Post date: [18 June 2021 14:32 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/1 "2021-06-18T14:32:18Z")

</div>

Hello  
i have a function node writing

msg.payload = {  
status: msg.payload.crc\_error  
}  
return msg;

the Output if error, is then status: false  
is there a way to on the fly

msg.payload.crc\_error if false write "CRC Error" else write the output

so the output message would then be CRC Error

have a nice day  
vinc

---

<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: [18 June 2021 14:38 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/2 "2021-06-18T14:38:49Z")

</div>

try

```auto
msg.payload = {
status: (msg.payload.crc_error ? msg.payload.crc_error : "CRC Error")
}

```

[edit]  
thinking about it this would be better

```auto
msg.payload = {
status: (msg.payload.crc_error || "CRC Error")
}

```

---

<div class="post-metadata">

### Author: ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)
#### Post date: [18 June 2021 14:41 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/3 "2021-06-18T14:41:28Z")

</div>

fast @E1cid thanks a lot  
looks spezial - will add it and wait

---

<div class="post-metadata">

### Author: ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)
#### Post date: [20 June 2021 08:39 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/4 "2021-06-20T08:39:16Z")

</div>

@E1cid thanks for your sugestion  
i try to understand what will happen 😉  
if the output status: false it will write CRC Error  
what happen it it write status: true would it be possible to have OK?

have a nice day  
vinc

---

<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: [20 June 2021 08:59 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/5 "2021-06-20T08:59:32Z")

</div>

Long hand (for clarity)...

```auto
if (msg.payload.crc_error == false)
  msg.payload.status = "CRC OK"; //or whatever message you want
} else {
    msg.payload.status = "CRC Error"; //or whatever message you want
}
return msg;

```

Shorthand hand ...

```auto
msg.payload.status = msg.payload.crc_error == false ? "CRC Error" : "CRC OK"; 
return msg;

```

---

<div class="post-metadata">

### Author: ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)
#### Post date: [20 June 2021 09:04 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/6 "2021-06-20T09:04:17Z")

</div>

thanks for the long Hand @Steve-Mcl now it is more clear to me.

---

<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: [20 June 2021 09:05 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/7 "2021-06-20T09:05:18Z")

</div>

Just replace msg.payload.crc\_error with "OK"  
eg

```auto
msg.payload = { status: (msg.payload.crc_error ? "OK" : "CRC Error") }

```

---

<div class="post-metadata">

### Author: ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)
#### Post date: [20 June 2021 09:27 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/8 "2021-06-20T09:27:18Z")

</div>

Merci, @E1cid & @Steve-Mcl for your help and clarification.  
Changed - and have to wait till message arrive 😉 it not a message flow more some message drops

---

<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: [19 August 2021 09:27 UTC](https://discourse.nodered.org/t/function-node-payload-change-text/47337/9 "2021-08-19T09:27:26Z")

</div>

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