Function node, payload change text

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

try

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

[edit]
thinking about it this would be better

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

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

@E1cid thanks for your sugestion
i try to understand what will happen :wink:
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

Long hand (for clarity)...

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 ...

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

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

Just replace msg.payload.crc_error with "OK"
eg

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

Regards
Andy

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

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