Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation

In this blog, we will see how can we create a folder in a SharePoint document library when a list item is created in a custom list.

Microsoft Flows is a Cloud based service that enables us to build workflow processes for different services. 

In this blog, we will see how we can create a folder in a SharePoint document library when a list item is created in a custom list. The folder will be created with the same name as of List Item “Title” column.

Triggers and Actions used,

  1. When an item is created
  2. Send an HTTP request to SharePoint

Explanation

When an item is created - This gets triggered when an item is created. The required parameters for this trigger are,

  • Site Address
  • List Name
Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation
 
Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation
 

Send an HTTP request to SharePoint

 
This action constructs a SharePoint REST API which needs to be invoked. The required parameters are,
  • Site Address
  • Method
  • URL

Since I wanted to create a folder in document library. Used the below REST call:-

/_api/web/GetFolderByServerRelativePath(decodedurl='/sites/InternsPOC/EmployeeDoc')/AddSubFolderUsingPath(decodedurl='')

Below headers need to be added to perform a POST operation,

  • Content-type = application/json;odata=verbose
  • Accept = application/json;odata=verbose
 Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation

Once Flow runs successfully, it can be tested and seen as per the below screen:-

 Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation
 

Output

List Name Used: CompanyJsom

Document Library Name Used: EmployeeDoc

When an item is created in the list, the folder got created in the document library, as shown below,

 Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation
 
Microsoft Flows (Zero to Hero Series) - Create Folder In A Library On List Item Creation
 

Summary

In this blog, we have seen how we can create a folder on list item creation using Microsoft Flows.Check all SharePoint actions and triggers in the below URL,

https://docs.microsoft.com/en-us/connectors/sharepointonline/ 

Sharing is caring!