Skip to main content

Notifications

Power Automate - Building Flows
Answered

Apply to each problem: Scheduled flow adds all attachments instead of per selected line

(0) ShareShare
ReportReport
Posted on by 76
I am building a scheduled flow that sends exam preparation assignments 14 to the student before the exam. I get the exam date from an Excel file, the date correction is done in Initialize var Date. So far so good.
Now I disappear in different Apply to each actions which leads to:
- an email is sent to each filtered line (that is ok)
- with all the different attachments (that is not ok, should only be the attachment from that one line)
- those attachments (pdfs) cannot be opened either.
All (very many) suggestions on the forum do not lead to a solution.
Where does this go wrong?
In a previously built flow with the trigger "For a selected row" the Get files (prop only) was not put in an Apply to each. What makes the difference here?
 
 
  • Verified answer
    chosen67 Profile Picture
    chosen67 76 on at
    Apply to each problem: Scheduled flow adds all attachments instead of per selected line
    In the meantime, we have made a lot of progress with the help of this forum and YouTube. The following adjustments have been made:
    After the "List rows present in a table" I have now placed a "Condition" in the "Apply to each" that checks whether there is anything in the Attachment column. That produces the correct output.

    I then created another Condition in which the Attachment names in Excel and in Sharepoint are compared. If the same: send an email with attachments.
    This does produce 22 actions (22 different attachments in Sharepoint) per email to be sent. I suspect that this could be shorter? Suggestions?
     
    In addition, there is a 'problem' with the PDF extension: the attachment in the email is not presented as a PDF. It can be opened as such with the correct content. If I change the name to xxx.pdf.pdf, the attachment is recognized as a PDF. Could this be a Sharepoint setting? It seems that the extension is not really in the name on SP, but that it is added to it?
  • chosen67 Profile Picture
    chosen67 76 on at
    Apply to each problem: Scheduled flow adds all attachments instead of per selected line
     
    In the meantime I have continued to puzzle, but have not made any progress yet:/
    Filter query in List rows present in a table is still Exam Date. With that I get 2 lines of Excel as output.
    The emails must then only be sent to those students who need the preparation assignment for a specific exam. So another filter is needed. I did that with a Filter array (in this case it can be filtered on the text "sprek", but it would be better if it were filtered on cells that contain something, but I don't know how to do that)
     
     
     
    The output from my filter yields 1 row (which is correct), but now the content of that row must provide 2 things: the email address in combination with the attachment that must be sent. In any case, the output provides the correct data from the selected line in Excel, including the name of the attachment to be sent
     
     
    How do I get that from the Filter array? That doesn't seem to be possible with Select. (see picture below) Because if I then choose Email again, it can only be from the Excel file that has not yet been fully filtered.
     
  • chosen67 Profile Picture
    chosen67 76 on at
    Apply to each problem: Scheduled flow adds all attachments instead of per selected line
    Thnx @SudeepGhatakNZ for your help,
     
    The filter query used is: Attachment (=Attechment) eq 'Attachment'. Even if I use Id eq 'Id' this results in an Apply to each.
    From the List row present in a table action (as output of the Exam Date filter) 4 rows from Excel come with all the data in them; including indeed the different Attachments per student.
     
    In another flow with the trigger "For a selected row" I used:
    = triggerBody()?['entity']?['Attachment_Formatted'] =
    and this returns concerning Attachment
    In my flow I now have no option to choose Attachment_Formatted as dynamic content.
     
    I can't figure out how I can now, just like in the "For a selected row", get the specific data (Get files (property only)) that yields the correct attachment per sent email.
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    Apply to each problem: Scheduled flow adds all attachments instead of per selected line
    You need to restrict your Get files action to only return files for a specific item.
    You need a filter clause like
    ID eq 'ID of the item'

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard