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

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

Leave a Reply to Scott McKenzie Cancel 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