Hi Benry!
I looked at your workflow and I think there are 2 problems:
- Keeping the data from the previous node when using Code nodes.
- Merge node should use the Keep Matches options.
Code Node
Generally what I’ve found is that you want to try and append data from one node to the next. So think of each node adding to or subtracting to a particular data item as it makes its way through the workflow.
What I can see in your Code 2 node is that you create a data object and then return that entire data object in the return statement, which means that the downloaded binary data retrieved in the Google Drive node is thrown away.
Instead, what I think you should do is keep the loop that iterates over each input item and append the data that you’re extracting from the filename (Jahr, Probenummber, Kundenummern, etc..) like this
for (const item of $input.all()) {
const parts = parseFilename();
const data = {
"Jahr": convertValue(parts[0] || ""),
"Probenummer": convertValue(parts[1] || ""),
"Kundennummern": convertValue(parts[2] || ""),
"Grund": convertValue(parts[3] || ""),
"Produktgruppe": convertValue(parts[4] || ""),
"Rebsorte": convertValue(parts[5] || ""),
"Geprüft für": convertValue(parts[6] || ""),
"Artikelnummer": convertValue(parts[7] || ""),
"NummerA": convertValue(parts[8] || ""),
"NummerB": convertValue(parts[9] || "")
};
item.json.data = data;
}
This will keep the binary object for each item (in fact in the code the n8n IDE will provide a hint when you type in item.binary.Bericht.).
You can read more about the Data structure in the docs.
Merge Node
It appears that you want to use the Merge node to lookup the email address and match based on Kundennummern however in the Output Type option you’ve selected Keep Everything. What this will do is actually ignore the Fields to Match option and merge all inputs. This means that items that don’t match will also get passed through from the google sheet (in other words items that were not downloaded from google drive and have no Bericht data).
But in order to filter the results so that only records where Kundennummernis the same, you should change this to Keep Matches.
If you follow the change that I made in the Code Node, the field Kundennummern is now inside another object called data so you’ll need to also enable the switch for Fields To Match Have Different Names and Input 1 Field would be set to Kundennummern but Input 2 Field would be set to data.Kundennummern
Finally, if you think I’ve solved your problem, please don’t forget to set this as Solution
!