10 May’19

D365 General, Dynamics 365

Create SharePoint Folder using POST request in MS Flows

Introduction:

This blog explains how to create folders in SharePoint when new record is created in D365 CE.

Use Case:

When new account is created in D365 CE create “Contact Documents” and “Documents” folders in SharePoint.

Pre-Requisites:

  1. D365 CE
  2. SharePoint Online
  3. Microsoft Flow

Steps to be followed:

  1. Sign in to the Microsoft flow. https://flow.microsoft.com/en-us/
  2. Go to My flows -> “+New”-> “+Automated-from blank”

3. Select “When a record is created” trigger and click on create.

4. Select “Organization Name” and “Entity Name”.

5. Click on “+New Step” and select “Compose” Action.

6.   a. Add “Account Name” from Dynamics Content in Input.

b.  Add underscore “_”

c. Click on Expression enter below formula:

toUpper(replace(triggerBody()?[‘accountid’],’-‘,”))

d. Compose should look like below:

7. Now we will create “Main folder in SharePoint” for this account.

8. Click on “+New step” and select “Send an HTTP request to SharePoint” Action.

9. Enter below details:

Site Address: Select the site address from the list.

Method: POST

Uri: _api/Web/GetFolderByServerRelativeUrl(‘account/Output of Compose‘)/Folders

Headers:

Content-Typeapplication/json;odata=verbose
Acceptapplication/json;odata=verbose

Body:

{ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’:’account/ Output of Compose‘}

10. Now we will create sub folders inside the main folder.

11. Click on “+New step” and select “Send an HTTP request to SharePoint” Action.

12. Enter below details:

Site Address: Select the site address from the list.

Method: POST

Uri: _api/Web/GetFolderByServerRelativeUrl(‘account/Output of Compose/Contact Documents‘)/Folders

Headers:

Content-Typeapplication/json;odata=verbose
Acceptapplication/json;odata=verbose

Body:

{ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’:’account/ Output of Compose/Contact Documents}

NOTE: “Contact Documents” is the sub folder which we want to create in main folder.

13.  Repeat “step no 12” to create “Documents” folders.

Uri: _api/Web/GetFolderByServerRelativeUrl(‘account/Output of Compose/ Documents‘)/Folders

Body:

{ ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’:’account/ Output of Compose/ Documents‘}

NOTE: “Documents” is the sub folder which we want to create in main folder.

Complete Flow:

Testing Flow

  1. Create new account record in D365 CE.
  2. Check Documents in SharePoint. 
Written by

Vaishali Vyas

Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • How to enable Document ID in SharePoint Online

    16 May’ 2019

    Introduction: As you know that SharePoint Online can be used as a document management platform and with the help of Docu...

    Read more
  • Count Number of files in SharePoint folder

    15 May’ 2019

    Introduction: This blog explains how to Count No of files in SharePoint folder using MS Flow. Steps to be followed:Sel...

    Read more
  • Professional Services Automation (PSA) for CPA firms

    14 May’ 2019

    With the evolution of Technology, every industry is getting process oriented and so are CPA firms getting more organized...

    Read more
  • What if the Resource Requirement Still appears post the task is deleted from Schedule (WBS) in PSA V3?

    13 May’ 2019

    Problem Definition: I have observed a fact in PSA that when the task in PSA Schedule (WBS) is deleted, the corresponding...

    Read more
  • Discount Settings for D365 Sales Line Items – Line Items or Per Unit?

    10 May’ 2019

    For Line Item entities Opportunity Products, Quotes Products, Order Products or Invoice Products, you can chose what typ...

    Read more
  • We respect your privacy.
  • This field is for validation purposes and should be left unchanged.