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 / get ID of a onedrive s...
Power Automate
Unanswered

get ID of a onedrive subfolder using Filter Array

(1) ShareShare
ReportReport
Posted on by 116
I want to get a list of the files in a OneDrive for Business subfolder, where the subfolder is a dynamic value. The path from the root is /fixedname/<dynamic value>. There are no files in /fixedname, only subfolders. And those subfolders will only have files, not additional subfolders.
 
I know that to get the ID of that subfolder, I have to go through a few steps before I can use the Get List action of the actual subfolder. The approach I was trying is:
 
  1. List Files in Folder on the static part - /Initial Grant Request in example below
  2. Filter Array on the 'value' array produced by List Files, with condition item()?name = 'dynamicname'.
  3. Then, I'd hoped that would give me just the element from that array that matches my subfolder, I can look at the ID, and then
  4. List Files in Folder using that ID, which would give me the list of files I want.
 
The test flow starts like this:
 
 
 
 
And in a test run (according to the Compose I inserted - body('list_files_in_folder')) the List Files does give me what looks like a 'value' array:
 
{
    "value": [
        {
            "Id""b!QxmkTU0IcUKwSTGqXhyybBtwH90DHyBEll5ukVqwLounIAZ-qbvMSZVMM_ICpWk3.01ULAD262XE4LCWT5FANGZ7XKCSEQ7BYBC",
            "Name""A Tree Falls, Inc. 05-19-2025",
            "NameNoExt""A Tree Falls, Inc",
            "DisplayName""A Tree Falls, Inc. 05-19-2025",
            "Path""/drives/b!QxmkTU0IcUKwSTGqXhyybBtwH90DHyBEll5ukVqwLounIAZ-qbvMSZVMM_ICpWk3/root:/Initial Grant Request/A Tree Falls, Inc. 05-19-2025",
            "LastModified""2025-05-19T16:44:54Z",
            "Size"13387,
            "MediaType""application/octet-stream",
            "IsFolder"true,
            "ETag""\"{2B162757-A54F-4D03-9FDD-429121F0E022},6\"",
            "LastModifiedBy":...
etc. 6 entries, matching the 6 subdirectories.
 
It's the Filter Array that I'm stumbling on. No matter what I enter in the From field, such as Copilot suggestions:
 
body('list_files_in_folder')
body('List_files_in_folder')?['body]?['value']
 
and variants such as wrapping in an expression using json(), or as in the test run above the Output of the Compose, the Filter Array action refuses to recognize it as an array.
 
I'm missing something silly.  I'm sure I can solve this inside a For Each loop, and then test each Name, but yikes this seems more complicated than it should be. Is there an alternate approach I should be using?  thx
Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,707 Most Valuable Professional on at
    I think the problem is in the use of name in the left side of the query, not the from.  That name should be a dynamic content value not just a string.  More like this

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • StewC Profile Picture
    116 on at
    Thanks @Pstork1, took me a while to get back to this.  You are correct -- and there's more!
     
    My head was stuck in Odata format, for filtering a Dataverse Get List query: col_name eq 'string_with_quotes'. For Filter Array, I had both the left- and the right-side of that query wrong.  Skip the quotes. Here's what worked:
     
    From:    Outputs('List_files')?['body/value']
    Filter query:   item()['name']      is equal to   subfoldername_without_quotes
     
    From there, the rest of the flow described in my first post was easy:
    use first() to get the ID for the first item in the filtered array  -- I'm only expecting one item, my subfolder of interest
    list_files again, this time based on that ID
    get metadata for each file
     
    ...etc.  
    Marking this one good, with thanks.  Stew

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard