I wanted to ask you if there is any node or in some way make a dynamic variable, for example I have a situation where I have several countries, with IF nodes, and depending on each country does a certain action and I would like to know if there is something to replace it since the countries are They are deregistering and registering all the time, I don’t know if I explained it.
Hi @Internalit_Automatio, I’m looking forward to a few days off, so I am very good . Hope you’re having a good day as well?
I understand you’re looking for an easy to change alternative to IF nodes that would return a value depending on a specific input variable? I think for a large amount of different cases the Code node can be a suitable alternative. This would allow using the switch statement which can handle a large amount of possibilities.
For example like so:
Depending on the input, this example returns either a result with additional details or an error field:
This allows you to easily add new options or removing old options the code node. Simply add another snippet like below or remove the old ones as needed:
case 'de':
$input.item.json[outputFieldName] = 'Germany';
break;
You can still use the IF node afterwards to handle any errors in your workflow if needed.
Hi @MutedJam Here in Argentina we come from 2 long holidays, so luckily resting hahahah.
Regarding what you told me, those 2 nodes helped me a lot, so I really appreciate this help! Then I wanted to ask you about some more situations that are coming up, such as: we’ve got a google sheet where are many suppliers, vendors, etc. Each one has specific information that we have to get from different columns and send an email with a new google sheet with the information of all fields that belongs to each supplier, so, we need to create a google sheet for each supplier and send it by gmail.
As always thank you very much for the help and have a great week!
Regards,!!
Hi @Internalit_Automatio, n8n really only shines when creating row based spreadsheets with items distributed across the rows in your spreadsheet. If that’s what you have in mind I think there shouldn’t be a problem creating a sheet for every item you read from another sheet.
Here’s an example:
The “Customer Datastore” node emulates your first sheet here, the loop then creates a new sheet for each of your items. To customize the columns in your new sheet you could add a Set node as well.
Running this workflow will create a new sheet for each of your incoming items: