You are generating a brand new msg in your function and therefore discarding the important data that tells the link-call and link-out to route the msg.
instead of setting msg = { ... } , just update the properties of the incoming e.g. msg.payload = ... so that the important stuff required by the link-call is left in tact.
As the message says, it cannot update something that is undefined. i.e. the things JUST BEFORE .icon - so make it "something" before you try to populate it.
With change node i would need to use another switch node, to differenciate true and false incoming payload, so thats why i thought i can do it in one place.