Create Folder Structure in SharePoint using MS Flows


In this blog we will see how we can create folder structure in SharePoint for Leads when the record is created in CRM using MS Flows

Pre Requisites:

SharePoint Integration must be enabled for the required entities


Step 1: Here in our Flows we have used “Create of a record(Leads)” as trigger condition.

Trigger Condition Lead creation

Step 2: Then we create the folder structure in SharePoint using the “Create File” action
Here we will create a text file which can be deleted later if not required.
Folder Path: /Lead/Topic_toUpper(replace(triggerBody()?[‘leadid’],’-‘,”))
Here “Topic” is Dynamics value and for the record ID copy paste the expression written above in the Expressions tab and add it at the end of the Folder Path.

Create main folder

After we have created the folder structure if the file is not required we can delete the text file by adding the delete step as shown below
Delete File

Step 3: We will also store the Folder ID in a variable “FolderId” to use in the later steps
FolderID variable

Step 4: Now we will create the same folder structure in CRM (Document Location)
Create Document Location 1

Document Location 2

Here for the parent site or Location we have we have added the GUID of the Parent Document Location site for Leads.
We can get this from the URL of the Parent Document Location record from Advanced Find (Document Location Entity)
Document Location Default Site

Lead document location record URL:

Step 5:  Similarly we can also create sub folders within the main folder as per the requirements

Hope this Helped!

Share Story :