I've created a new fairly generic node, its a common pattern I found myself doing that involved a combination of switch and change nodes so I merged that into one, I couldn't find any existing solution for this?
The concept is that you have a field in your incomming message that you want to change or add to the message based on its value, for example in a phone call scenario looking up a number and adding a name.
In larger systems you might want to handle this with an external database but in many systems there are only <10 values that you need to insert.
Thats the purpose of the lookup node, it looks at a source field eg msg.payload and then matches the value of that in its internal table to an output value and writes that value to the target field eg msg.out, You can set source and target to the same eg msg.payload and it will replace the source value with the target.
There's a couple of options for how to handle no match, eg pass thorugh, set default value or drop to 2nd output.
Have a look at the example flow included to see the full range of configurations,
Published at node-red-lookup (node) - Node-RED and in the pallete manager when the catalog action catches up.
