Use Power Automate to create a folder in SharePoint with link back to Microsoft Lists

In this blog post I will out line how Power Automate can be used to create a folder in a SharePoint document library and then store the link to the newly created folder inside of Microsoft Lists. I have used this pattern numerous times for business processes where transactional metadata and document storage are required. For example, a case management list stores the business process data and the folder stores the supporting documents.

I am using a list called “Exchange Agreements” in this blog post. You can replicate this Exchange Agreements using the my spreadsheet (see below) and these instructions: Microsoft Lists: new list using an existing Excel spreadsheet

Let’s start by adding a new “Hyperlink” column to the Exchange Agreements list called “FolderLocation”.

Create a column

Create a new Flow from by clicking “Automate” > “Power Automate” > “See your Flows”.

See your Flows

Create a new “Automated – from blank” Flow.

New automated Flow

Provide a name for the Flow i.e. “Exchange Agreements – New”; select the “When an item is created” SharePoint trigger and then click “Create”.

SharePoint when an item is created

Set the “Site Address” and “List Name” to you target site and list.  

SharePoint when an item is created

Click “New step”, search for “Variable” and select the “Initialize variable” action. Set the “Name” to “varFolderName” and “Type” to “String”.

“Value” should be set to something unique, readable and short. In my demo, I combine school name and exchange type for a value of “University of South Australia (Undergraduate Programs)”.

Power Automate expressions and the concat function work well in these situations. Here is the expression I use:

concat(triggerOutputs()?['body/Title'], ' (', triggerOutputs()?['body/ExchangeType/Value'], ')')

Initialize variable

Click “New step”, search for “SharePoint” and select the “Create new folder” action.

Set the “Site Address”, “List or Library” to you target site and document library, and “Folder Path” to “varFolderName”.

Create new folder

At this point the folder has been created and now we have to update the list with the URL path to the folder.

Click “New step”, search for “SharePoint” and select the “Send an HTTP request to SharePoint” action.

Set the “Site Address” and “List Name” to you target site and list. 

Also set:

  • “Method” to “POST”
  • “Uri” to “_api/web/lists/GetByTitle(‘Exchange‘)/items(ID)
    • Where ‘Exchange’ is the list name and ID is the “ID” from the SharePoint “Create new folder” action
  • “Headers” – switch to text – to:
    {
    “Content-Type”: “application/json;odata=verbose”,
    “X-HTTP-Method”: “MERGE”,
    “IF-MATCH”: “*”
    }
  • “Body” to:
    {‘_metadata’: {‘type’:’SP.Data.ExchangeListItem’},’FolderLocation‘: {‘Description’: ‘varFolderName‘, ‘Url’: ‘LinkToItem‘}
    }
    • Where Exchange is the list name; FolderLocation is the column name; varFolderName is the variable and LinkToItem comes from the “Create new folder” action.

My completed Flow looks like the image below:

My completed FLow

Save your Flow and test by submitting a new item to your list. If all goes well the new folder will be created and a link to the folder will be added to the list item.

Folder created
List item with folder link.

This pattern can be beneficial for large volume lists and folders. The folder location URL serves as a simple pointer to the supporting documents and negates the need for the user to search or navigate to the folder.

Thanks for reading.

NY

18 thoughts on “Use Power Automate to create a folder in SharePoint with link back to Microsoft Lists

  1. Great and valuable blog which will add huge business process benefits!
    Question – off topic – if you have a Microsoft List created can you adjust power automate to send emails to line managers and customers so for example power automate can send a bulk email which includes 3 of 4 items in the list which require them to action?
    At the moment I have setup power automate to send emails per individual item. Managers want 1 email alert not 3 or 4 emails per item on the list.

    Like

    1. Hi Amardip,

      Yes, you can set up a message with multiple items. The key to the solution is that the message body needs to be compiled before the send mail message action executes. This sounds like a great idea for a future blog post.

      Thanks for reading!

      Norm

      Like

  2. Hi, this is very helpful, but I am getting stuck on the last step. I am getting the error “An entry without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified.” I did exactly what was specified above. I’m not able to post a screenshot here it seems…

    Like

    1. Hi MarRayn,

      Check that the ExchangeType is populated with a valid entry. The ExchangeType is part of the variable definition and ultimately becomes the folder-link name.

      I’m happy to help further and thanks for reading.

      NY

      Like

  3. Thank so much for your reply! In my version, I had to replace “exchange type/value” with “title”. So, my variable is: concat(triggerOutputs()?[‘body/ID’],’_’,triggerOutputs()?[‘body/Title’]). I was able to create a file name that is “ID_Title”.

    I’ve been able to narrow down the issue to something wrong with the Uri or body of the “send http request to SP”:

    Body:
    {‘_metadata’: {‘type’:’SP.Data.Sales-Training-Development-RequestListItem’},’Link1′: {‘Description’: ‘@{variables(‘varFolderName’)}’, ‘Url’: ‘@{outputs(‘Create_new_folder’)?[‘body/{Link}’]}’}
    }

    The list name is “Sales-Training-Development-Request”. “Link1” is a hyperlink column in my list. I’ve also tested with a second column, “Link2”, which is a one-line text field and wasn’t successful with either.

    I was also having some trouble with my Uri, but I thought I managed to fix it:

    _api/web/lists/getbytitle(‘Sales-Training-Development-Request’)/items(‘@{outputs(‘Create_new_folder’)?[‘body/ID’]}’)

    Thank you for any insight you can provide! I appreciate you taking a look at this!

    MR

    Like

    1. Hi MarRayn,

      You are missing an underscore on metadata. “_metadata” should be “‘__metadata”.

      Test and let me know how you make out.

      NY

      Like

  4. Hi Norm,

    Trying to do as described.

    I am having trouble getting the API call Uri” to work
    The expression “web/lists/GetByTitle(‘MDSNET21_CUSTOMER_PROJECTS‘)/items(99)” is not valid.
    clientRequestId: 4b44b4c6-9e66-439d-8651-dac79c3ca318
    serviceRequestId: 5ba8b09f-5068-2000-9324-ede1db259587

    Where MDSNET21_PROJECT_LIST is the list where i want to add the URL and the ID is the correct one
    I Cannot find out why flow fails

    Question : when someone changes the name of the list to something else, it will not work anymore, because the name is hardcoded?

    Like

    1. Hi Wilfried,

      Check your single quotes and ensure that they are ‘ and not ‘. WordPress is messing up my code formatting.

      Thanks for reading!

      NY

      Like

  5. Hello! This looks like what I need but I need to both create the list AND the folder structure at the same time. Since I’m not that experienced at Power Automate, do you have any particular guidance you can provide or pointers I need to keep in mind.
    Thank you.

    Like

      1. Thanks you for your very kind reply, Norm.

        I have an excel list of 600 topics that I’d like to import. Of course, the new list imports fine and has some metadata I’d like to keep. Account name; account number; owned by; classification etc.

        Whether during the import OR afterward, I need to add the new folders to the document library and then update the imported list with the link. I’d like to concatenate the account name and account number as the new folder name.

        I read the instructions and they are Greek to me. Do have have an example of carrying out such a task or how shall we proceed?

        Like

      2. Hi Cindy,

        This is definitely possible and the Flow pattern in this blog post can be used as a reference point. The major difference is you are running this Flow in batch and will require a different trigger (i.e. Scheduled) and a listing or rows to process (i.e. SharePoint get items and a loop).

        I’m happy to help you with this Flow if you like.

        NY

        Like

  6. Hi – I tried your “Send an HTTP request to SharePoint” but could not get it to work. I found a much easier way with “Update item” – so simple it was crazy after spending about 3 hours trying your way.

    Like

    1. Hi Fiona,

      Sorry to hear that you couldn’t get it to work. The syntax is very particular and I know I have had similar “3 hours trying”. My preference for this Flow would have been to use the Update item action but at the time of developing this pattern adding a hyperlink with a description was not supported and as far as I know, it is still not supported. How did you do it?

      Thanks for reading!

      NY

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s