SharePoint is fantastic in everything related to files, so having Power Automate automating things in the background is even better. Today we’ll check on the SharePoint List folder action and how we can use it to help us deal with files and folders if they exist.
So let’s look at it in more detail.
Where to find it?
To find it, you can search for the “List folder” action or check on the “Standard” tab:
Pick “SharePoint“
Power Automate tends to save the most common actions in the main screen, so check there before going trough the full hierarchy. Also you can use the search to quickly find it.
You’ll get the list of all SharePoint actions.
Scroll down and you’ll find the “List folder” action.
Here’s what it looks like:
Usage
To use it, you only need to define the SharePoint where it’s pointing and the file identifier. There are two essential things to keep in mind here:
- The “File” is misleading since we’re looking at folders. You’ll understand below why this is this.
- It expects the file “Identifier” and not its “Path.” It’s a standard error, so please keep this in mind.
When it runs, we’ll get the list of everything in that folder, with the following information:
- “Id” – This is the identifier that we need to use in other actions.
- “Name” – The name that you see in the folder view (when you see the file in your computer’s file system, for example), including the extension.
- “Display Name” – This is the name that is displayed in the “list view” (when you navigate in SharePoint’s site and see the file as an item of a list)
- “Path” – Where the full path where the object is located.
- “Last Modified” – When was the file last changed, including when it was created.
- “Size” – The size of the file in bytes.
- “MediaType” – The media type can be quite cryptic, but it’s a convention that identifies the type of file. For example, an Excel is represented as “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”
- “isFolder” – One of the most valuable flags indicates whether an item is a folder or not. Therefore, it’s handy for filtering purposes. Also, I think this is why I believe the action contains the “File Identifier” and not the “Folder identifier.”
It’s a lot of information but notice that we don’t get the file’s data. To fetch it, you need to use the “Get file contents” action.
Limitations
Although there’s a similar named action for OneDrive, we can’t use this one to fetch files from there. It’s not quite a limitation, but since OneDrive is supported by SharePoint, it would be a stretch to bring files from there.
Recommendations
Here are some things to keep in mind.
Avoid as much as possible having static IDs.
You should have an excellent reason to have static IDs in the “List folder” action. However, it’s dangerous to do it since SharePoint controls it. It can generate silent errors and a lot of problems. Instead, pick the item from the UI or use an ID from a previous action to ensure it exists and it’s future-proof.
Name it correctly
The name is super important in this case since we’re defining the folder but only getting its name and not the full path. Always build the name so that other people can understand what you are using without opening the action and checking the details.
Always add a comment.
Adding a comment will also help avoid mistakes. Indicate why we’re looking at this folder and what you’ll do with the data. Also, indicate if you’re interested only in the folders or files (or both). It’s essential to enable faster debugging when something goes wrong.
Always deal with errors.
Have your Flow fail graciously and notify someone that something failed. It’s horrible to have failing Flows in Power Automate since they may go unlooked for a while or generate even worse errors. I have a template, and a template that you can use that will help you make your Flow resistant to issues. You can check all details here.
Back to the Power Automate Action Reference.
Photo by Jubal Kenneth Bernal on Unsplash
hi Manuel,
could you guide me on how to move folder from Sharepoint to Onedrive on form submission. I tried to follow below forum instruction but not able to get this to work properly.
Tried this earlier but not working, seeking your guidance on how to move folder from sharepoint to onedrive
https://powerusers.microsoft.com/t5/Building-Flows/Moving-folder-from-SharePoint-to-OneDrive/m-p/441576#M52121
tried this earlier but now working for me. Seeking help.
https://powerusers.microsoft.com/t5/Building-Flows/Moving-folder-from-SharePoint-to-OneDrive/m-p/441576#M52121
In my case I use : Get files (properties only) – & Link to item