cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
STLMDV
Regular Visitor

Order By ODATA Value in Sharepoint Get Files (Properties Only) - Folder Name or Path

I have a Flow that emails and HTML Table of all Files Created or Modified in all sub folders in the last 7 Days.  Flow works as designed EXCEPT, I want to order the output in the HTML table by the Sub Folder Name that houses the file, ascending order.

 

This would essentially group all the files by folder in the HTML Table.   Is it Possible to use the ODATA Orderby field to set the order of the data pulled by the folder path or folder name? 

 

Something to  the affect of "Folder Path asc"  I have tried countless variations of this and continually get errors stating the field/column doesn't exist  

 

 

SharedScreenshot - Flow 1.3.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User II
Super User II

There are some hidden columns for the documents in SharePoint, among them 'FileRef', which contains the whole file path including file name. You can use that in the Order By, just put there:

 

FileRef asc

 

and it'll sort the result by folder(s), subfolder(s) and file name.

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

6 REPLIES 6
tom_riha
Super User II
Super User II

There are some hidden columns for the documents in SharePoint, among them 'FileRef', which contains the whole file path including file name. You can use that in the Order By, just put there:

 

FileRef asc

 

and it'll sort the result by folder(s), subfolder(s) and file name.

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

abm
Super User III
Super User III

Hi @STLMDV  & @tom_riha 

 

I just tried couple of options including the FileRef and it didn't worked as expected.  Initially I thought I could utilise FullPath which is the folder path but Filter Query only accepts a valid columns names.

 

Sorting array would have been a good option here but you could vote for this idea.

 

https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Sort-Array/idc-p/486807#

 

Unfortunately you won't be able to do this via Power Automate Sort Order property.

 

You have couple of options:

 

Write a custom function and execute via HTTP but you need some dev effort to achieve this.

 

Other option is please below link it explains how to sort some numeric values. 

 

http://johnliu.net/blog/2018/12/how-to-implement-sort-with-microsoft-flow-in-3-actions-within-a-loop

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Thank you so much, that did!

 

By Chance, do you know of link, document or method to lists these hidden columns?

@abm To me it looks fine, why do you think it's not working? Left side is using Order By = FileRef asc, right side doesn't have any Order By = sorted by defaut by ID?

image.png

@STLMDV for example here: https://dipansaha.wordpress.com/2012/07/23/useful-reference-for-sharepoint-internal-fields-name/



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
abm
Super User III
Super User III

Hi @tom_riha 

 

Thanks for your reply.  Please see below.

 

 

image.png

 

Here aj is my library, x1 and a are the folders

 

The other question you asked about internal fields name. Here it is.

 

https://dipansaha.wordpress.com/2012/07/23/useful-reference-for-sharepoint-internal-fields-name/

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

@abm I see what you mean, it's sorting by folder levels, and you'd like to sort it by the full path. I didn't see any issue because that's the sorting I expected.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,325)