October 16, 2024

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

Pro Tip:
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:

  1. The “File” is misleading since we’re looking at folders. You’ll understand below why this is this.
  2. 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:

  1. “Id” – This is the identifier that we need to use in other actions.
  2. “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.
  3. “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)
  4. “Path” – Where the full path where the object is located.
  5. “Last Modified” – When was the file last changed, including when it was created.
  6. “Size” – The size of the file in bytes.
  7. “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”
  8. “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.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Jubal Kenneth Bernal on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

4 thoughts on “Power Automate: SharePoint – List folder Action

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon