Power Automate: Uploading multiple files to SharePoint in one go

  • LFF_IT
    Asked on March 25, 2022 at 6:58 AM

    Hello!

    Your file upload widget allows multiple files to be attached. I want to be able to upload multiple files in one go into SharePoint. One of your support team posted this solution:-


    https://www.jotform.com/answers/2358500-how-to-upload-the-files-in-a-submission-to-sharepoint-through-power-automate

    Am I right in thinking this will only upload one file into a SharePoint Document Library?

    If so, this solution won't work for me, as we have clients who need to upload an unknown number of documents. Can you help with this?

    Best regards,


    Mike D!

  • Leonidas JotForm Support
    Replied on March 25, 2022 at 7:13 AM

    Hello Mike D,

    Thank you for reaching out to Jotform Support. Base on the thread, one of my colleague also shared the option to upload multiple file into a SharePoint. Please see the image below:

    1648206729 623da3892fb26  Screenshot 10

    If you need further assistance, please let us know.

  • robertsonldspj11795
    Replied on March 25, 2022 at 7:24 AM

    I also have this same question and i cannot find any proper answers on the internet and also here. need solution.
  • Sheena JotForm Support
    Replied on March 25, 2022 at 7:49 AM

    Hello robertsonldspj11795,

    Thank you for reaching out to Jotform Support. To avoid confusion, I have moved your concern on this thread. I will be assisting you there.

  • LFF_IT
    Replied on March 25, 2022 at 10:24 AM

    Thanks for your response.

    So am I correct in thinking that the solution you posted will only upload a single file for each file upload widget? If so I presume it's necessary to change the settings on the widget to have a maximum file upload of 1.

    However, this doesn't solve my original problem because our clients need to upload an unknown number of documents. If they definitely needed to upload for example 3 documents, I could use 3 file upload widgets all with the same Power Automate flow. But if I don't know how many they are uploading (it could be 10 even) I don't know how to do this.

    Do you think there's a clever way of making Power Automate iterate through multiple files attached to the file upload widget, and create each file in the SharePoint Document Library?

  • LFF_IT
    Replied on March 25, 2022 at 10:31 AM

    Also I really think that Jotform should implement two features:-


    1. Ability to upload multiple form attachments into a SharePoint Document Library using Power Automate.
    2. Ability to upload multiple form attachments into a SharePoint List Item as attachments.


    There must be huge demand for these two features. I could literally use Jotform for so many more applications if it could do this.

  • John Support Team Lead
    Replied on March 25, 2022 at 10:47 AM

    Hello Mike,

    To answer your question, yes, the workaround shared by my colleague in this ticket is meant to send a single file to SharePoint.

    Regarding your requirement to upload multiple files, I'm not sure if it's possible, but allow me some time to test this out on my end, and get back to you here with my findings.

  • John Support Team Lead
    Replied on March 25, 2022 at 2:49 PM

    Hi again Mike,

    After several tests, I was able to upload multiple files into a SharePoint folder in a single automated flow. I used the same principle as that of solution provided in the ticket shared with you and added/removed a few actions. Here's what I did:

    Action 1:

    1648230573 623e00ad1544e  Screenshot 10

    Instead of using 'HTML' format, I used 'Text'.

    Action 2:

    1648230800 623e019061352  Screenshot 21

    I used HTTP GET method to capture the URI of the uploaded files. Now, since I used 'Text' format, the result will be an archived file (zip):

    1648230909 623e01fd4b530  Screenshot 32

    instead of hyperlinks being provided when using 'HTML' format:

    1648231472 623e04303f03c  Screenshot 43

    Action 3:

    1648231984 623e06303c8fd  Screenshot 54

    Here I initialized a variable I called "getURL" extracting the value from the HTTP GET action. This results into the actual URL of the archived file.

    Don't forget to configure run after settings to include "has failed":

    1648232245 623e073506819  Screenshot 65

    Action 4:

    Here I used HTTP GET method again then selected the variable I just created from Action 3 as the URI

    1648232772 623e094411b1b  Screenshot 76

    Action 5:

    This one's optional but I find it handy to create the filename on a separate action. In this particular action, I just concatenate the "name" field in the form with the "submission ID" as the unique filename of the archive:

    1648232937 623e09e960bcc  Screenshot 87

    The filename depends on how you prefer it to appear in SharePoint.

    You may learn more about this function here.

    Action 6:

    Now here's the exciting part. I have used 'CREATE FILE' action in SharePoint and used the output from the action 5 as the filename appended with ".zip":

    1648233208 623e0af85969a  Screenshot 98

    And the BODY of HTTP method in action 4 as the file content:

    1648233461 623e0bf55e2ea  Screenshot 109

    This will be created in SharePoint:

    1648233769 623e0d298cb3e  Screenshot 1110

    Action 7:

    Now, since a zip file was created in the SharePoint folder I just defined in the previous action, I'll now extract it into a separate folder that'll contain the actual uploaded files:

    1648233690 623e0cdadc4ad  Screenshot 1211

    This will be the result:

    1648233823 623e0d5f609d3  Screenshot 1312

    1648233860 623e0d849f521  Screenshot 1413

    Action 8:

    And lastly, I have created an action to delete the archived file so only the extracted ones will be retained:

    1648233958 623e0de6cbf12  Screenshot 1514

    I used 'ID' as the file identifier which can be found from searching 'ID' in the Create File action's content:

    1648234107 623e0e7bc4219  Screenshot 1615

    And that's it! I have implemented this on my test form and it worked as intended.

    Please try it on your end, too and see if it'll work for you.


  • LFF_IT
    Replied on March 28, 2022 at 10:58 AM

    That is indeed a very clever workaround @JohnRex. I will implement this soon and let you know how it went. Many thanks for this!