Create Folder Structure in SharePoint using MS Flows

Introduction:

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

Implementation

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: https://org.crm8.dynamics.com/main.aspx?etc=9508&extraqs=%3f_gridType%3d9508%26etc%3d9508%26id%3d%257b1957C431-5F15-E911-A96F-000D3AF29269%257d%26rskey%3d%257bF5B008AC-07D9-4554-8509-2C05767BFF51%257d&histKey=17520860&newWindow=true&pagetype=entityrecord&rskey=%7bF5B008AC-07D9-4554-8509-2C05767BFF51%7d#371473802

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

Hope this Helped!


Share Story :