How to delete message parts in function node

I know the change node allows you to delete parts of a message.

What command do I use in a function node to get the same thing done?

Thanks.

Have a read of this and see if you apply it to individual properties.

https://nodered.org/docs/user-guide/writing-functions

Example:

msg.topic = null;

@bobo Thanks. Looking.

@krambriw Yeah, and the msg. still have those properties listed in the debug window (or next node) when it arrives.

I would prefer to not have them listed at all.

Then

delete msg.topic;

Would you like to elaborate on that?

I'm stupid.

I admit it.

I don't know if the command delete msg.foo exists.
Yeah, ok: I maybe should have tried it before posting. See above.

Shall try soon.

I try always BEFORE I post :wink:

1 Like

Then you are better then me. What can I say?

You are still trying to learn,,,,the same as I do !!!

No worries, it aint easy all the things to handle, I know, just realized this after upgrade to 1.0

I'm not going there yet. Too scared of what I may find.

If the stuff you have today aint working yet, you better fix that first before upgrading, at least I think so. If you have used a lot of code in function nodes, you should really look into how you wrote that code. We had discussions about that, maybe you noticed?

Yeah, well...... That's a whole other thing.

I am now re-writing a lot of code to make it nicer/better/(something else) so it is of higher quality.

I think that is 100% ongoing as there is no defined layout of what is wanted.

As I am writing, I see other/better ways of doing things and over 10 RPIs and 2 NUCs, it is painful when I have 2/3's of NO PROGRAMMING KNOWLEDGE.

All this started less than 3 years ago.

NR probably less than 2.

I think, coming back to the topic, this is a better example for you (using code in function nodes). You can run it and study the differences in the msg sent to debug

[{"id":"32ac6a9a.e0dc56","type":"inject","z":"60f50465.20a53c","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":700,"y":100,"wires":[["b4e5c41d.c24248"]]},{"id":"b824f72c.176208","type":"function","z":"60f50465.20a53c","name":"","func":"node.warn(msg);\ndelete msg.payload.Who;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":100,"wires":[["f6e4cc5d.086d4"]]},{"id":"f6e4cc5d.086d4","type":"debug","z":"60f50465.20a53c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1230,"y":100,"wires":[]},{"id":"b4e5c41d.c24248","type":"function","z":"60f50465.20a53c","name":"","func":"msg = {\"topic\":null,\"host\":null,\"_msgid\":\"a2c057de.049818\",\"_topic\":null,\"payload\":{\"Who\":\"TimePi\",\"device\":\"UpLink\",\"UpLink\":\"Online\"},\"_event\":\"node:97bcd5bc.1a76e8\",\"condition\":\"Online\"};\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":100,"wires":[["b824f72c.176208","9caca000.d752f"]]},{"id":"9caca000.d752f","type":"debug","z":"60f50465.20a53c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1070,"y":170,"wires":[]}]

Thanks.

I indulged your suggestion and just put the line
delete msg.(what ever part);

And it is deleted.