How to upload a file to a Parent and Sub Library in SharePoint?
Below instructions demonstrates how to upload two files to the Documents library of one's SharePoint site (i.e. https://yourSharePointWebsite.com/sites/Site-Name):
Prerequisites:
- Create sample files File1.txt and File2.txt
- Create a sub-folder within Documents Library named "Test"
Steps:
- File1.txt will be uploaded in the root folder of the Documents library.
- File2.txt will be uploaded in the "Test" sub-folder of the Documents library.
Before running the workflow, the content of Documents library should look like below (Test sub-folder should exists):
Workflow Description:
- First, add a Microsoft Office 365 Scope activity in order to connect to Office 365 and to provide a scope for other Office 365 activities
- Then, add Find Files And Folders activity in order to find and return the Drive Item corresponding to "Test" folder.
- Query := "Test"
- Site Url := "https://yourSharePointWebsite.com/sites/Site-Name"
- (Output) → mySharepointFolder (this represents the Drive Item object corresponding to "Test" folder)
- Secondly, to retrieve the Drive Item for the Documents Library root folder, use Get Item Info activity with the following values for the parameters:
- Item ID := mySharepointFolder.ParentReference.ID (i.e. the parent of the "Test" folder drive item)
- Site Url := "https://yourSharePointWebsite.com/sites/Site-Name"
- (Output) → mySharepointRootFolder
- Upload the Drive Items files : File1.txt to mySharepointRootFolder and File2.txt to mySharepointFolder. Upload first File1.txt:
- Upload File2.txt to mySharepointFolder
- Execute the workflow
- Post successful execution, see the result in browser
- Files shall be uploaded successfully.