web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter list by names a...
Power Automate
Unanswered

Filter list by names and get attachments from those list items

(0) ShareShare
ReportReport
Posted on by 253

Hi,
As the title suggests, I am trying to get items() from my SharePoint List, then extract the attachments from those items to prepare them for printing.
At the very least, I want it to return the attachments zipped together by name so that we can more easily print them rather than having to manually print 160 items from the SharePoint List.
There are 2 lists at play here. One is a sort of Employee Roster, the other one has each employee listed 16+ times, for a different file or certification the employee holds. Think of it like a digital file cabinet.

The first few problems I am running into:

 

1. There are A LOT of items in this 'File Cabinet' list, apprx 16-18 per employee (we have 400+ employees). Originally, I was going to search the employee roster first, then use those 10 outputs to search the "file cabinet". But logically, that only increases the information the flow has to sort through, so I dropped that idea.

 

So, accessing the 'File Cabinet' List, I first need the flow to:
FilterQuery(Manager Name(and filter query TriggerFlow(outputs)).
The problem is, I cannot seem to pull the 10 outputs down from the Trigger, and into the Get Items()Filter Query (it won't accept them as filterable data). Also, if we can manage to do it, I think sorting through thousands of items for 160 items is going to be an overflow of information.
I assume that I need some variation of Select/Compose, but it must be easier than Select(all 10 outputs), assigning them ID's, then manually Compose(Item()?['Employee1-10']. Also noticing that it may be smart to include manager name in the Trigger(outputs)

*I realize that none of code is properly formatted for what I am trying to do, I am merely using it to get across the gist of the functions, not to show what I currently have.*

 

The gist of it is, by the end of this first operation I want it to return 10 (for each) loops (one for each employee listed), and with each loop containing the 16-18 list items under that employee's name.

 

Update: There may be a way to create an item() from the User_Display_Name within the Trigger, then use that for the Get Item Filter Query, as the Managers will be the one's pulling the information.
(The manager column in the 'file cabinet' is a plain text generated from the 'person column' on the 'Employee Roster', so it may be possible to use this for the query.)

 

2. The get attachments portion should be fairly simple once I am able to:
ForEach(Get Attachments(Filter Query(Get Items['ItemID'])))
*use the IDs from the Get Items action to Filter the Get Attachments action*

 

3. The last problem is how to package and deliver the attachments once they've been gathered.
Easiest may be to send them over email? Flow-to-Print isn't really an option.
Genuinely not sure on this one.
But end result is: we need all attachments associated with Employee 1 grouped together, then 2, 3, and so on.
If the files get out of order, it could create a massive headache that would make this whole flow obsolete.

Images of List and Flow start for reference:

Tmalonson_0-1692371618828.png

Tmalonson_2-1692371922533.png

 

 



Categories:
I have the same question (0)
  • Verified answer
    Tmalonson Profile Picture
    253 on at

    Problems Solved:
    A bit lengthy, so I will try to save you some of the details.
    Here is the gist of it.
    By creating a trigger flow (Text input), I was then able to use those inputs via Variables, Select, and Compose(Item) actions I was able to create variables that were usable for the filter query. Namely: Employee Name & Manager Name.

    Tmalonson_0-1692732644311.pngTmalonson_1-1692732684702.png

     

    Then, from the Get Items() result, I ran a FOR EACH('Get_Items') - Get Attachments(body('Get_Items')?['ID']))

    *In other words, using a "For Each loop" I got the attachments using the IDs from the Get Items() search.*
    Once I had the Attachments, then For EACH(Get Attachment) Get Attachment content.

    Once you have attachment content, then you need to Append to Variable Array (which has to be initialized in the root of the flow).

    The code that goes within the Append to array is as follows:

    {
     "name": "@{items('For_Each_Attachment')?['DisplayName']}",
     "contentBytes": {
     "$content-type": "@{body('Get_attachment_content')?['$content-type']}",
     "$content": "@{body('Get_attachment_content')?['$content']}"
     }
    }

    Note: the code following "name":  is simply the dynamic value for the file name. Make sure to delete the code within the quotation marks and select the "DisplayName" dynamic content to make sure the code is correct.

    Tmalonson_2-1692732981203.png

    Once you have done this, you may prepare the email for delivery of the files.
    Most notably, make sure that the attachment is in the written code, and only contains the Append to Array output.

    Tmalonson_4-1692733339442.pngTmalonson_5-1692733405432.png

    Now, compose your email however you like.
    I chose to have the user select the recipients in the Trigger, and used the outputs from the Trigger to fill to "To" field.


     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard