Geeks With Blogs
SharePoint Wiki! Sharing is gaining...

This post covers a step by step guide to add/update data from InfoPath to SharePoint.

The prerequisites for this post and the tasks covered are SharePoint 2010 and Microsoft Office

InfoPath Designer 2010 installed on your machine. 

Having a good understanding about CAML(Collaborative Application Markup Language), a 

knowledge of the methods of the SharePoint Lists web service would be really helpful.

To get more information about the SharePoint Lists web service:

Open IE navigate to "http://servername/_vti_bin/lists.asmx?WSDL

(You will be able to see all the web methods associated with the Lists web service. For our 

purpose we will be using UpdateListItemsweb method).

STEP 1. Create a Custom List in a SharePoint Site, 'Employee'. Also create some columns as 

per your need. 

Note that there will be a default column called 'Title' and lets not change it and keep it that way to 

store EmployeeName, I've create EmployeeAddress, EmployeeNo, EmployeeEmail as columns 

which are Single text. 

STEP 2. Open Microsoft Office InfoPath Designer 2010 and select a Blank Form and click 

Design Form. Then do as follows.

Form Options

Security and Trust

Full Trust





Renaming the button

Add fields

STEP 3. In SharePoint site under Employee list, in ribbon under List Tools select List and then select List Settings. In that page click Advanced Settings and select Allow management of content types to Yes.

List Settings

STEP 4.  Again go to List Settings click Metadata navigation settings and copy the list GUID.

Copy list GUID

STEP 5. Go back to InfoPath form right click on listID and paste GUID under value field.

STEP 6. Open Notepad and type,

<?xml version="1.0" encoding="UTF-8" >?
<Method ID="1" Cmd="New">
     <Field Name='Title' />
     <Field Name="EmployeeAddress" />
     <Field Name="EmployeeNo" />
     <Field Name="EmployeeEmail" />

Save the file as an xml file and name it Submit.xml.

STEP 7. Now lets create Data Connections. Go to InfoPath form and click Manage Data Connections. First we need to create a Receive Data connection. I am naming it as 'Submit'.

Receive Data

XML Document

Browse for the created Submit.xml file

Naming the connection as 'Submit'

STEP 8. Now we need to create a Submit Data Connection. Again in Manage Data Connections click Add.


Submit Data

To a Web Service





Include : Text and child elements only




Include : XML Subtree, including selected element

Web Service Submit

Edit Form Code

STEP 9. Click Edit Form Code and btnSubmit_Clicked event will be created. In that block, type the following code.

    XPathNavigator root = MainDataSource.CreateNavigator();

    // Retrieve the values for the separation list item
    string listID = root.SelectSingleNode("/my:myFields/my:listID", NamespaceManager).Value;
    string eNameDS = root.SelectSingleNode("/my:myFields/my:EmployeeName", NamespaceManager).Value;
    string eAddressDS = root.SelectSingleNode("/my:myFields/my:EmployeeAddress", NamespaceManager).Value;
    string eNoDS = root.SelectSingleNode("/my:myFields/my:EmployeeNo", NamespaceManager).Value;
    string eEmailDS = root.SelectSingleNode("/my:myFields/my:EmployeeEmail", NamespaceManager).Value;

    if (listID == null)
        //This is CAML xml file. it contains batch and method nodes
        XPathNavigator batch = DataSources["Submit"].CreateNavigator();

        batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']", NamespaceManager).SetValue(eNameDS);
        batch.SelectSingleNode("/Batch/Method/Field[@Name='EmployeeAddress']", NamespaceManager).SetValue(eAddressDS);
        batch.SelectSingleNode("/Batch/Method/Field[@Name='EmployeeNo']", NamespaceManager).SetValue(eNoDS);
        batch.SelectSingleNode("/Batch/Method/Field[@Name='EmployeeEmail']", NamespaceManager).SetValue(eEmailDS);

        DataConnections["Web Service Submit"].Execute();
catch (Exception ex)

STEP 10. And finally thats all. Preview the form and try submitting the data. After that publish the form and upload the form template into SharePoint and start using.

There are few important things to remember carefully. 
  • There is a significant difference between Display name and the Field name. When we are doing the coding we are using the value under the Field name. If you can remember, I have mentioned to keep the default 'Title' column as it is, because if we rename the 'Title' column it will just change the display name. The Field name will be remain as 'Title'.
  • No of updating list fields should be the same as no xml field names.
  • When I am creating columns in SharePoint list, if you can remember I have included no spaces between words. Thats because it will add characters into Field names. So when we are referring to Field names from looking at Display names, the Field name is actually differs from the Display name.
  • List fieldname should be same as xml fieldname.
  • Make sure when creating the Submit Data connection 'Web Service Submit' to select following things,
    • listName - listID : Include : Text and Child elements only
    • updates - Batch : Include : XML subtree, including selected element
Posted on Monday, April 30, 2012 3:48 AM | Back to top

Comments on this post: How to submit data from an InfoPath 2010 form to SharePoint 2010 List, in just 10 Steps

# thank you!
Requesting Gravatar...
thank you for posting this.
you have one small mistake on the XML.

<?xml version="1.0" encoding="UTF-8" >?

should be:

<?xml version="1.0" encoding="UTF-8"?>
Left by ian on May 25, 2012 6:22 AM

# re: How to submit data from an InfoPath 2010 form to SharePoint 2010 List, in just 10 Steps
Requesting Gravatar...
Iam getting this error
The form cannot be submitted because of an error.
Click OK to resume filling out the form. You may want to check your form data for errors.

Hide error details
An error occurred while trying to connect to a Web service.

An entry has been added to the Windows event log of the server.
Log ID:5567

Correlation ID:8c64b5e5-4aa6-4937-9d20-faaacc4f0be6
Can you please help me
Left by swathih on Sep 26, 2012 11:52 PM

# re: How to submit data from an InfoPath 2010 form to SharePoint 2010 List, in just 10 Steps
Requesting Gravatar...
Will this work for offline InfoPath forms in SharePOint workspace?
Left by Binu on Dec 13, 2012 4:00 AM

Your comment:
 (will show your gravatar)

Copyright © KunaalKapoor | Powered by: