Monday, November 11, 2013

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

It was extremely, insanely hard to get a proper reference to a way to upload InfoPath attachments to a SharePoint document library WITHOUT CODE. I hope this will help you or at least point you in the right direction.

This is for SharePoint 2010.

Firstly in the InfoPath form, create a Query web service Data Connection.
Make the web service call to /_vti_bin/Copy.asmx.wsdl.

Next, select the CopyIntoItems method. Leave all fields blank and proceed to assign the data connection a proper name.

In the InfoPath form, I have some fields that are populated with default values.
Later, I will use those values to pass as parameter to the web service.
The fields are as below:
The FileName is an input field that the user needs to fill. e.g. Document1.docx
The LibraryUrl will serve as the destination Url, and it is a calculated value.

The Link will store the final URL of the document in the SharePoint document library.

My form design will look like this:

Now let's start stringing all pieces together.
Add rules to the Upload Document button. We need to set the values of some of the fields, before making a query for data.

In the collection of "Set a field's value" above, all the fields are actually referring to the queryFields for the data connection.

For reference, the FieldInformation node in the CopyIntoItems method need to contain SharePoint properties to be associated with the document library. I tried to leave the field blank but it would result in errors. For simplicity's sake, I will just populate the Title.
Please refer to the link below on how to retrieve the Id for FieldInformation. It's actually the GUID for the field, which you can find out by looking at the document content type.

Finally, add one more rule to Upload Document to populate the link.

That's it! Happy discovery!

Related Posts Plugin for WordPress, Blogger...