Dynamic File Naming in Automated PDF Workflows: Resolving Duplicate Attachments

Hello, I need help with this workflow. My goal is to generate invoices in PDF format according to each route. First, I fill out a Word template, upload it to OneDrive, and then use the tool to set multiple variables. I define two variables: one for the file ID from the “upload a file” module and another for the file name. This allows me, in the final step, to use an iterator that gathers all the file IDs with this function: {{remove(add(emptyarray; 54.CC1; 54.CC2; 54.CC3); null)}}, in case any file ID or document is not generated, so I can later download them as PDFs.

When I download the files in PDF, their names change to “File export to PDF,” so I use an iterator again, this time to retrieve the document names that I set in the variables ({{remove(add(emptyarray; 54.Cost 1; 54.Cost 2; 54.Cost 3); null)}}). Then, in the array, I configure the structure in the Gmail - send an email module, in the attachments, and I set a custom name using the value from the last iterator.

The problem is that this iterator runs twice, generate 2 operations with the same bundle output, and instead of attaching three documents with different names, it generates nine files: three with the first variable’s name, three with the second, and three with the third. What alternative can I use to dynamically name the files according to the variables from each route?

Way to @Nats24 for stepping big into making life easier with Make automation.

Would you please create a Loom video or the like demonstrating the scenario in operation to include seeing what the output bundles look like to help with further debugging?

Thanks!