Then an email goes out to the related parties for each individual order received
What I want to do is create a digest that sends all of the information about the imported orders in one email instead of getting 11 emails for 11 orders. How would I combine the records mid-flow to send one email for all transactions instead of one email for each transaction?
If you set your page size high on your export, then you can fit all the records into one page. Everything would stay the same until you hit the email import, where you’d configure it to use “Number of records per HTTP request” and match it to your page size. That way, you only send one API call per page of records.
The catch is the 5 MB page limit. If you have a low volume of orders this works fine. If not, you’ll still cut down on the number of emails but won’t always get it down to just one.
If you want a guaranteed approach, you’d need to chain two flows together. The first flow handles the orders and creates a JSON file of the fields you want along with something to group by. The second flow runs right after, grabs that file, groups by that field (could be a job id or just a static value), and then sends the email. Since everything from the prior run shares the same grouping value, you end up with one digest email instead of many.
I tried setting the page size on the export to 20 and the number of records to 20 and I get the following for each record in the file. (In this case I got it ten times)
I thought that it could be an issue with the transform because on the transform I only get one record and am reconstructing each of those records. I also get one record in the preMapData as well. However, when I took the transform out, I ended up with the same thing as rows.
This is due to batch imports needing the response of the batch to supply a status for all records sent. In your case, you're sending 20 records in 1 email, so your response back is just one email. Luckily, we are changing this behavior in the September release so that the response path to records for batch imports will be optional, and when not set, it will propagate the response to all sent records as opposed to trying to match.