I want to transfer data from a trigger node to an application via HTTP-request. The trigger node provides the salutations like
Mr.
Mrs.
Company
as a text string. The receiving application expects a salutation id like “1” for Mr., “2” for “Mrs.” and “3” for “Company”. I thought about using an array with the possible values and applying something like VLOOKUP, but I was not able to find that.
There are a couple of approaches, but seeing you have only 3 possible options here I’d probably go with a raw n8n approach instead of writing any code. Here’s a quick example of how to use the Switch node and a couple of Set nodes for the job:
If you prefer a shorter workflow instead and don’t mind a little code, a close enough JavaScript replacement for VLOOKUP would be a switch statement. This can be used in a Code node. Here’s a quick example:
Each option would leave you with a new salutation_code field which you can then use in your subsequent workflow: