none
Uploading InfoPath Multiple Attachments to SharePoint Document Library using Webservices RRS feed

  • Question

  • Hello,

    Our case is that we have an InfoPath form designed using InfoPath2007 and is published to a SharePoint 2010 Forms library as a content type.

    This form has an attachment control in a repeating section so that users could add multiple documents but to minimize the form's size, we want on submitting the form (we are currently doing this using code) to take the attachments , upload them to a document library, add links to these documents in the form and delete the attachments.

    I found the two following related links that apply something similar but using Server side object model

    http://www.bizsupportonline.net/blog/2010/upload-document-sharepoint-infopath-form.htm

    http://tihomirignatov.blogspot.com/2009/09/attach-files-to-infopath-form.html

    But I want to know if I could apply this using web services and also I want to know how to iterate over all attachments in the repeating section.

    So if you could please advise.

    Thank you in advance.

    Regards,

    Marwa Mosafa

    Monday, June 24, 2019 12:08 PM

All replies

  • Hi Marwa,

    You could create a custom web service to get the attachments in InfoPath Form and upload them to a document library.

    For creating the custom web service and code logic inside the web serivce, you could refer the following code demo:

    Custom SharePoint Web Service – Upload InfoPath Attachmet

    Another code less option is to call the Copy.asmx web service directly inside InfoPath to upload attachment into a library:

    How to upload InfoPath 2010 attachments to a SharePoint document library without code

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, June 25, 2019 5:40 AM
  • Hi Jerry,

    Thank you for your reply.

    I didn't mean to have a custom web service but I want to use the std MS web service "Lists.asmx" where I will use it in InfoPath form code instead of using SharePoint.dll to access SP sites and lists. I was thinking for example to use "Lists.UpdateListItems" but I don't know if this will work.

    Also, my second question is how to iterate over the attachments in the repeating section??

    Thanks & Regards,

    Marwa Mostafa

    Tuesday, June 25, 2019 7:53 AM
  • Hi Marwa,

    To upload attachments files to a document library, you could use copy.asmx, this is also the OOTB SharePoint web service:

    /_vti_bin/Copy.asmx.wsdl

    For more detailed information, please check the second link in my previous reply.

    Lists.asmx is not suitable in this case, as this is not updating normal custom list item field with UpdateListItems method, this need to copy file stream into a new destination library path.

    Here is a sample code from official document for your referecen:

    Copy.CopyIntoItems Method

    For iterating over multiple attachments in InfoPath, this need to do with XmlDocument C# class:

    How to Read the InfoPath content and extract the attachment using XMLDocument in C#

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, June 25, 2019 9:45 AM