cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IPC_ahaas
Responsive Resident
Responsive Resident

Ge SharePoint File Identifier by Name

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

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


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
Pstork1
Dual Super User
Dual Super User

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


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
IPC_ahaas
Responsive Resident
Responsive Resident

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.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,878)