Loop - where to place in a workflow

I have a situation where I need to read in file attachments from an email inbox and append the date to the actual file (the data source, for some reason, can’t append a date). Therefore, I need to ‘offset’ the email date by -1 ('yesterday) and append to the attachment which contains ‘yesterday’s’ data. I create a specific subfolder in the inbox so that these specific emails are isolated. The workflow reads the email (one at a time in the event that the data doesn’t get processed and ensure the proper date is associated with the proper attachment), writes to the attachment to a temp folder locally, converted to .xml extension (passes as .xls). Workflow reads the .xml, parses the data, appends the date, creates the table, then joins with a ‘master table’ - deduping any data (if applicable), then updates the master file. The final step is moving the attachment from the specific inbox location to a ‘processed email’ folder to retain a history.


Here’s my question - where do I place the start/end loops? I believe i chunk loop so i can process one file at a time? If I manually run this workflow, it works perfectly. I run the workflow, reset all nodes, then execute all, it cycles through all of the emails.

However, I’d like to just hit run and have it cycle through all emails until there aren’t anymore emails in the inbox folder. I think I need a case switch (if email inbox is empty, then stop, if email exists, then pull one email at a time until completed). Where do the loop start/ends get placed? I want the loop to end after the last email has processed (written to the master table and the email from the inbox is moved to the processed folder in the inbox).
Step 1: Read email:


Step 2: pass attachment through, convert email date to yesterday:

Step 3: create unique filepath/file name, convert from .xls to .xml, move file to TEMP folder on local machine

Step 4: Read .xml file, parse date, create table in proper format:

Step 5: Append date and file name to data table:

Step 6:

Move file from Temp folder on local machine to an archived/processed folder, dedupe and update the master data file, and move the email from the inbox to a processed folder in the email inbox to keep inbox clean.

Are these nodes I need, and where in the workflow do I insert them to ensure accuracy?

@ebarr you might take a look at these two articles that should give you the basics. Then you will have to plan where to put your nodes. Most important to cover the alternative and closeb the loop or case switch.

1 Like

thank you - will take a look

1 Like