cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

Emailing an Excel file with a table only emails the first row

Same as this question but the solution there isn't helping.

 

My flow is as follows:

  1. Triggered by a button in Power Apps
  2. List rows present in a table (Excel file hosted on OneDrive Business)
  3. Apply to each row above, delete the row (resets the Excel file to empty)
  4. List rows present in a table again (same Excel file)
  5. Compose, find length of value of #4 (number of rows in the Excel file)
  6. Condition, check that Compose #5 = 0 (confirm that the deletion in #3 was complete)
    1. If No, do nothing
    2. If Yes,
      1. List records in my CDS entity
      2. Apply to each record above, add row to a table (same Excel file that was emptied)
  7. List rows present in a table again (same Excel file)
  8. Compose, find length of value of #6.2.1 List Records (number of records in the CDS entity)
  9. Compose, find length of value of #7 (number of rows in the Excel file)
  10. Initialise variable "Timer" = addSeconds(utcNow(),20)
  11. Delay until Timestamp = Timer from above
  12. Condition, check that Compose #8 = Compose #9 (confirm that adding rows was complete and the Excel file is ready with all data present)
    1. If No, do nothing
    2. If Yes,
      1. Get file content using Path (same Excel file)
      2. Send an email with attachment same Excel file from above

 

My CDS entity always has more than 1 record so this is definitely an issue. Right now it has 5 records.

 

When I check my run history both Compose #8 and Compose #9 always matches, so Condition #12 always goes to Yes. Compose #9 is always the correct number I want and it's never 1, which should mean my Excel file is fully populated and ready. I've even added a wait timer at #10 to give OneDrive a bit more time AFTER it's already reported having the correct number of rows. 

 

But when I get the file content, the email attachment always just has 1 row in it.

 

WHY? I don't get it. There are no further changes to the Excel file after adding rows at #6.2.2. Flow is telling me it has 5 rows. If it has 5 rows at #7 List rows, it should still have 5 rows at #11 Delay until, and it should still have 5 rows at #12.2.1 Get file content. I've bloodied CHECKED and CONFIRMED that it has 5 rows AND I've given it extra time BEFORE doing get file content/send mail, and yet somehow when it's getting file content, waaaaay at the end after alllll the checks and balances, it goes down to 1 row only.

 

The solution given in the linked post at the top said to add a minute delay. If it comes to that sure I'll do it but I'm not happy about it. My flow without the 20s wait timer takes a mere 10s! Adding 20s is already a 200% loss in efficiency.

 

Alternatively, is there a way to force the Excel file to save or refresh or recache or whatever, so that any delay I need to add just needs to be what it takes to save a file, and not an arbitrary number of seconds that we think should be enough for Get file content to grab the right contents?

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (7,362)