web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
Power Automate - Building Flows
Answered

Ge SharePoint File Identifier by Name

Like (0) ShareShare
ReportReport
Posted on 23 Sep 2022 14:25:42 by 1,374 Moderator

I am trying to get the Identifier of a file in SharePoint by its filename so I can delete it. The file came from a Form and I get the filename with:

 

 

first(body('Parse_Dust_Blown_Out_Photo_JSON'))['name']

 

 

When I use "Get files (properties only)" with a Filter Query of:

 

 

FilenameWithExtension eq '@{first(body('Parse_Dust_Blown_Out_Photo_JSON'))['name']}'

 

 

It says the file is not found.

 

When I don't use a Filter Query and I output the "Get files (properties only)", it shows the file is there:

 

 

[
 {
 "ID": 562,
 "{Name}": "bruce-banner_Adam Haas",
 "{FilenameWithExtension}": "bruce-banner_Adam Haas.jpg",
 "{Path}": "Shared Documents/Apps/Microsoft Forms/Daily Mulch Checklist/Photo of Dust Blown Out/",
 "{FullPath}": "Shared Documents/Apps/Microsoft Forms/Daily Mulch Checklist/Photo of Dust Blown Out/bruce-banner_Adam Haas.jpg",
 "{IsCheckedOut}": false,
 }
]

 

 

IPC_ahaas_0-1663943124858.png

 

So what am I doing wrong?

I have the same question (0)
  • Baytars Profile Picture
    10 on 01 Mar 2023 at 01:11:47
    Re: Ge SharePoint File Identifier by Name

    @Pstork1 wrote:

    If you use the regular dynamic content you don't have to encode the path.  But if you build the path from scratch as a string you do need to encode it or you'll get an error because it doesn't know how to handle the special characters.


    I first used dynamic content to check if I input in the correct format. The path looks unencoded. Before I saw this post, I never know what was wrong. Thank you!

     


    @Pstork1 wrote:

    The docs rarely discuss how to enter raw content into these fields.


    Thanks to my experience as a web developer, I know `encodeURIComponent` does this job.

  • Pstork1 Profile Picture
    68,214 Most Valuable Professional on 28 Feb 2023 at 22:51:11
    Re: Ge SharePoint File Identifier by Name

    If you use the regular dynamic content you don't have to encode the path.  But if you build the path from scratch as a string you do need to encode it or you'll get an error because it doesn't know how to handle the special characters.  The docs rarely discuss how to enter raw content into these fields.

  • Baytars Profile Picture
    10 on 28 Feb 2023 at 15:43:32
    Re: Ge SharePoint File Identifier by Name

    That action never says we have to encode the path.☹️

  • IPC_ahaas Profile Picture
    1,374 Moderator on 23 Sep 2022 at 15:25:26
    Re: Ge SharePoint File Identifier by Name

    Thank you! That is so much simpler as I don't need to get the file details since I already have them. This worked great.

  • Verified answer
    Pstork1 Profile Picture
    68,214 Most Valuable Professional on 23 Sep 2022 at 14:34:20
    Re: Ge SharePoint File Identifier by Name

    The file identifier is the relative path to the file, but it needs to be encoded so that all the special characters are changed to their HTML equivalents.

    So if the file name is test.txt and its stored in Folder 1 of the Shared Documents library in SharePoint then the relative path is

    /Shared Documents/folder 1/test.txt

    Putting that inside a encodeUriComponent() provides the following output which is the file identifier.

    %2FShared%20Documents%2Ffolder%201%2Ftest.txt

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 707 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 499 Moderator

#3
chiaraalina Profile Picture

chiaraalina 312

Last 30 days Overall leaderboard
Loading complete