Tag Archives: SharePoint Folders
Renaming SharePoint Folder using Microsoft Flows
Introduction: Using MS Flows, On any trigger, you can add the below action to rename the SharePoint folder. Steps: 1) In Actions, select “Send an HTTP request to SharePoint” 2) Enter the below details: Site Address: Select your site address from the list. Method: POST Uri:_api/web/GetFolderByServerRelativeUrl(‘LibraryTitle/CurrentFolderName’)//ListItemAllFields Headers: Accept application/json;odata=verbose X-HTTP-Method MERGE If-Match * Body: { Title :”New Name of Folder” FileLeafRef’:”New Name of Folder” } 3) The Folder Name in Uri and new folder names in body can be dynamic as per your requirement( Refer Screenshot below: the data here is taken directly from the trigger when file is created in SharePoint). Sample Output: Conclusion: Simple SharePoint Connector in MS Flows can help to rename a SharePoint Folder.
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: D365 CE SharePoint Online Microsoft Flow Steps to be followed: Sign in to the Microsoft flow. https://flow.microsoft.com/en-us/ 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-Type application/json;odata=verbose Accept application/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-Type application/json;odata=verbose Accept application/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 Create new account record in D365 CE. Check Documents in SharePoint.