In a custom node, I only want to output msg information that meets certain conditions. Other msg information that does not meet the conditions should not output any information when passing through the custom node.
other msg.payload information passing through this node is displayed as undefined. I want undefined information not to be displayed. How do I set this?
Thank you for your reply.
I assume you mean to be NOT displayed in the debug output?
Then you would delete the property.
e.g. delete msg.payload.a_prop_i_dont_want
This is a bad idea. Many users expect the msg to still have properties that they placed in the msg to still be there after traveling through your node - for later use downstream in the flow. In fact, what you have written breaks many things (dashboard, HTTP to name a few - since they EXPECT msg.xyz to be present).
Far better to simply update the property you care about then return the original msg object
If your problem is that the entire payload is sometimes undefined:
a) Use a switch node after your function to pass only messages whose payload is not null.
or b) Only call node.send(msg) when msg.payload is relevant - inside your if() block.