the ‘Loop’ branch from the ‘Loop Over Items’ has ‘10 items’
but the ‘Done’ has ‘126 items’
What is the error message (if any)?
No error
Please share your workflow
Share the output returned by the last node
i cannot share the output, but the ‘Done’ should (i think) run once containing a list of object, but it’s the case for the first run of the ‘Done’ branch, after that it run multiple times.
The first the run of the ‘Done’ branch is correct, it’s the data that i want.
Thanks for your answers. I’ve looked into it and I think my issue is in my loop that processes the files. I have 10 items that are going into loop process, at the end of this branch, I have a Merge block in ‘append’ mode. The problem is that it gives me 17 outputs (5 pdf and 12 images), and my branch ‘done’ in the looping is called 2 times for a total of 31 items. So the problem is indeed in this loop but the issue is, i don’t really know how to fix this, in code it would have been easier for me because i’m used to it, but n8n it’s hard because it’s like a new language. Anyway i have posted the pictures.
Thanks for the fast reply, in fact i want to at some point reconstruct the object with the data,
like
{
// unique id
'emailid': 'abcdef'
// coming from the processed loop
'pdf_extracted': ["content1", "content2"],
'img_extracted': [""] // (if any)
// original field
'field1': any,
'field2': any,
}
that’s what you can see on the code after the ‘Done’, i totally forgot to mention it, but because it’s an email, sometimes it has pdf, and sometime it has picture, ( in all the attachments ) and sometime nothing (not on my test data but can happend), or even both it’s hard to follow what is happening, that’s why i was saying it’s easier on code (not the node code).
Because you could
for (const currentEmail of listOfEmails) {
currentEmail.pdf_extracted = [];
currentEmail.img_extracted = [];
for (const attachments of listOfAttachments) {
if (attachments.type == 'pdf') {
currentEmail.pdf_extracted.append(extractPdfData(attachments.rawData)); //something like this
} else {
currentEmail.img_extracted.append(openAi.ImageAnalyse(attachments.rawData)); //something like this
}
}
}