I am a new user to N8N and it is very user friendly but I have a scenario I cant get to work properly and it seems very simple.
I get info from a Webhook that contains a field “ServiceLevel”. This field cane be 1 of 5 different value. I need to trasnform this value based on the criteria below to a SET that contains a ton of other fields I need
What I am trying to do in a SET Expression, but it doesnt work
I have tried the switch mode and I can make it work but I have to replicate all steps after that and wanted to keep the workflow simple. Is there a way to create a switch mode and have results concatenate back into single set based on the results of the Switch(0,1,2, etc)
You would better be using Code Node, with this expression:
var shipmentType = $node["*Name of the node you are getting data from*"].json["body"]["shipmentType"];
switch (shipmentType) {
case "LTL": {
var newShipmentType = "FTL-LTL" }
case "Truckload": {
var newShipmentType = "FTL-Truck" }
case "Domestic Freight": {
var newShipmentType = "Airfreight" }
default: {
var newShipmentType = "Small Package" }
}
return {
json:
{
"newShipmentType": newShipmentType
}
}
Or just use a Switch node, that was suggested above.