Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Submitting to a SharePoint List

Submitting to a SharePoint List

Rate This

As you know, submitting to a Microsoft Windows SharePoint form library from an InfoPath form is quite simple: just add a “submit” type of data connection to InfoPath and away you go. However, submitting to a SharePoint List is another matter. In this post, we will take a look at the steps necessary to enable this functionality.

Step 1: Create the list

1. Create a new custom list named: MyContacts
2. From the Settings button choose List Settings
3. Click Create Column
4. Add the following columns/data types:

  • FirstName, Single line of text
  • LastName, Single line of text
  • Email, Single line of text
  • Phone, Single line of text

The next step is to create a Collaborative Application Markup Language (CAML) template that contains the same XML nodes as the columns we added to our list – this will be used as a secondary data connection in the InfoPath Form Template.

Step 2: Create the CAML template

1. Launch Notepad (or any text editor)
2. Copy and paste the following code to the Notepad document:

<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Continue">
    <Method ID="1" Cmd="New">
        <Field Name='Title'></Field>
        <Field Name="FirstName"></Field>
        <Field Name="LastName"></Field>
        <Field Name="Email"></Field>
        <Field Name="Phone"></Field>

3. Save this as: Add List Item Template.xml


Step 3: Create the InfoPath Form Template

1. Create a new, blank, browser-compatible form template
2. Add a “Receive” type secondary data connection to the Add List Item Template.xml file created in Step #2. (Make sure the options “Include the data as a resource file in the form template” and “Automatically retrieve data when the form is opened” are enabled.)
3. Add a “Receive” type secondary data connection to the “MyContacts” SharePoint List created in Step #1 and make sure the option “Automatically retrieve data when the form is opened” is enabled.
NOTE: Be sure to include the “Title” field along with the custom fields we created.

Each SharePoint list is created with a unique identifier called a GUID. In order to submit items to a SharePoint list, you must know the unique GUID for that list. These next steps will enable you to identify the GUID for your “MyContacts” list.

Step 4: Identify the list GUID

1. Open a browser and navigate to the MyContacts list
2. From the Settings menu choose List Settings
3. In the browser’s address bar you will see the URL appended with “List=”


4. Copy everything after the equals sign and paste this into a text editor as we will need this value later on.

NOTE: We will need the list GUID to be formatted as “{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}”. If your GUID appears as above with the hyphens and braces “escaped” (i.e. %7B for the braces and %2D for the hyphens) then you will need to replace the escaped characters with the braces and hyphens so when we use this GUID later, it will appear as: {1E76517B-2C36-4473-A420-A737D98589BC}

Step 5: Add controls to the InfoPath Form Template

1. Open the Data Source Task Pane
2. From the Data Source dropdown box choose the “MyContacts” connection

3. Right-click on “MyContacts” and choose Repeating Table – this will add a repeating table bound to that connection to your View
4. From the Data Source dropdown box choose Main
5. Add a text box to the “myFields” node named: ListName and set the Default Value property to the GUID value of your list – we will use this node to specify the list when we perform the Submit operation


To update the SharePoint list we will be using the “UpdateListItems” method of the SharePoint “lists.asmx” web service. This web method requires a couple of parameters (the list name and what gets updated) – now that we have added the “ListName” node which contains the GUID and we have the Add List Item Template XML data connection which describes our data structure we have all the necessary information to add the “UpdateListItems” web method!

Step 6: Add the “lists.asmx” web service

1. Add a new “Submit” type of web service data connection to the “lists.asmx” web service – this is typically located at: http://servername/_vti_bin/lists.asmx
2. Select the “UpdateListItems” operation
3. Double-click the “listname” parameter and assign the “my:ListName” node as the value

4. Double-click the “updates” parameter, select the “Add list Item Parameter” data source, select “Batch” and click OK
5. For the “Include” option select “XML subtree, including selected element”

6. Complete the Data Connection Wizard

Now that we have all the connections that are required, we now need to add the “submit” functionality to the form template.

Step 7: Add Submit functionality

1. Display the Data Source Task Pane
2. From the Data Source dropdown box choose the Add List Item Template data connection
3. Drill down through the data source, right-click on the Field node and choose Repeating Table


We need to change the text box control in the “Name” column to Read-only – if these values were to be changed it would affect the CAML and the submit would fail.
• Double-click on the text box in the Name column of the Repeating Table
• Select the Display tab
• Enable the Read-only property and click OK
• Add a new Button control to the View
• Double-click the button to display the Properties
• Click the Submit Options button
• Enable the option “Allow users to submit this form”
• Enable the option “Perform custom action using Rules” and click the Rules button
• Click the Add button
• Click the Add Action button
• From the Action dropdown box choose “Submit using a data connection”, select the “Web Service Submit” data connection and click OK
• Click the Add Action button
• From the Action dropdown box choose “Query using a data connection”, select the “MyContacts” data connection and click OK (this will automatically refresh the list in InfoPath so you can see the newly added record)

• Click OK until you are back to your form

NOTE: If you want to automatically clear out the submitted values, add another action to this Rule to “Set a field’s value” and the only option you need to specify is the “Field” option – select the “Field” node from the “Add List Item Template” data connection and then simply leave the Value option blank.

Step 8: Test!

1. Click the Preview button to preview the form
2. Fill in values for each of the fields: Title, First Name, Last Name, E-mail and Phone

3. Click the Submit button – the contact information should be submitted successfully and the “MyContacts” list automatically updated!

A special thanks to Matt Faus of InfoPathDev for for initially posting this solution!

Scott Heim
Support Engineer

Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post
  • This is an awful lot of work just to submit information to a SharePoint list from InfoPath. Why doesn't InfoPath just have a "Submitting to a SharePoint List" wizard to simplify all of this nonsense?

  • Dear scout

    thanks for your great post,I try to macke contact-coment and coment list  view with infopath 2010 ,is this article can help me?

    i want have contact view with edithing ability and new coment plase and coment list behand it with one infopath form ,i mack it with webpart in web ,but when i whant work with worksoase i have problem with new item coment part ,

    plese help me

  • Charlie - I agree...this is a lot of work to submit to a SharePoint list; however, this is no longer required if you use InfoPath 2010 and SharePoint 2010 (Enterprise) - you now have the ability to create a list in SharePoint and then customize the form using InfoPath! When you publish the modified form back to the list, your InfoPath form is now what will be used for display, edit and new! So now it is much, much better. :)

    Garni - my apologies but I don't understand what you are trying to accomplish or the problem you encountered. Please provide additional details and I will do what I can to help.


  • Hi Scott.

    It worked like a charm, but I would like to use a drop-down box in the repeating table Situation is like this: Company A has a new employee and must be added to the company list. My thought was that, with a drop-down box the company could be choosen, and the rest of the standard company info will be filled out by the use of filters, but the data for the new employee must be added manually,



  • Hi Troels,

    Sure - this is possible. Look through the comments in this post...I know there are a lot of them but I have provided exact steps for doing this. However, it is important to note that if you want to change the design as you describe (and honestly, most people do) then exactly how you do this will depend on whether or not you are using your InfoPath Form Template in the browser or in the InfoPath client. You can do this without any code if you are using the InfoPath client; however, if you are using the form in the browser then you will need to use code to get the submit to work. Regardless, both designs are in the comments - in fact, there is also sample code if you decide to go that route. :)

    One other point: the ability to "submit" to a SharePoint list is now out of the box functionality if you have InfoPath 2010 and SharePoint 2010 Enterprise Edition. You didn't mention what versions you are using so if it is 2010 as described above, you may want to look into this new feature so you don't have to go through all these steps.


  • Hi Scott

    Thanks for the quick response. I will look through all comments as you suggested( lots of coffee) We are running on sharepoint 2007, and no decision has yet been made to change to 2010 :-(



  • I know this ios a real old post, but I am stuck using old SW and need some help please.

    Using this data here in the quest to populate a SP2007 **List** from a web enabled InfoPath 2007 form, the use of CAML is required. I can't quite figure out what the role of the CAML XML file is. The data connection associated with the CAML XML file "Retrieves" data, but is that only because this write-up uses repeating tables? In my situation, I am not using repeating tables. I am only trying populate a series of existing column in the list with data entered in the web enabled InfoPath 2007 form.

    What is the role of the CAML XML file when you want to populate a "List" from a web enabled InfoPath form?

    Thank you for any insight.

  • Hi Quized Again,

    Have you followed the steps in this post? Although it does show on the InfoPath view as a repeating table, you can only submit one item at a time. The CAML XML file is what is used to update the list. Notice the "cmd=New" in the XML file? This is the command to add a new item to a list. If you review all the comments on this post (I know...there are a lot) there are complete steps to submit to a list in other manners. Some are specific to the InfoPath client and some will work in both the client and the browser.


  • Dear Scott,

    Thanks for the post even though I'm thanking over 4 years after the fact. Some of us are still in the stone age... In any case I'm wondering if you might be able to point me in the direction of how to make a custom form without the repeating table. The data constraints are simple, but my customer would really like this form to look like the old one.

    Is this possible with 2007 sharepoint and 2010 infopath?

    I'm sure it would require editing the CAML, but I just started in infopath and do not have any clue how to edit it.


  • Hi EZ E,

    This has been asked a number of times...I know there are a lot of comments but if you go through them you will find complete steps for how to design the XSN so it does not use a repeating table. Do take option you will find described will only work in the InfoPath client (and this is noted as such.) If you need one that works in the browser then you will need to use the code option documented in the comments...and it is complete with sample code.


  • Hi Scott

    First a note on what programs I use. I currently run IP2010 to a MOSS 2007.

    I am trying to make a form to be published on sharepoint, which has a drop box in it, and I have followed the instruction in the blog dated 18 Nov 2008 4:31 AM, on page 13, but I get a failure note when I try to run/preview it.  It says “There was build errors”

    In the button property box I have used the action: “Rules and Custom code” and added the code in the “Edit Form code” button  

    In the code  I have corrected is the // before information lines to a single ‘, and the text turned green as expected

    In note 3 of the post I assume that the Listname should be a field, just like in the original sample, and the rest is fields as well.

    In note 7 where the submit function and code is described, you mention  ”InnerXml” for the Rich text, what is ”InnerXml” ?

    Should the field[1] in //values from the main DOM

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[1]", ns).SetValue(xnTitle.Value); be change to match the fields from “gpTestList (Group)“?

    Another question: Is there a way to make the fieldnames in my form look better, instead of CustomerName I would like it to be Customer Name.

    I have tried the decription on page 8, 17 Dec 2007 10:25 AM, but it doesn’t work.  Any suggestions?

    Br Troels

  • Hi Br,

    Without having your code, I am not sure why you are getting the error. If you double-click the error it should take you to the exact line that is failing. Maybe that would give you an indication? It sounds like you are using VB.NET instead of C#.NET? If this is the case, then it may be an issue of conversion - if you want to post the code that produces the error I will see if I can determine what is wrong.

    In regard to making the field names "look better" - just change the "label text" that appears next to the control. This does does not have to remain as "CustomerName" - you can easily change this to "Customer Name".


  • Hi Scott

    I have come the solution a little closer.

    The code I use is the one used in the post on page 13, but posted 09:45 AM instead of 04:31 AM

    I was indeed using VB instead of C#.

    I figure how to change that under developer and then language.

    However I still get an error message, but this time its when I try to submit my preview. The error message looks like this

    InfoPath cannot submit the form.

    The OnSubmitRequest event handler returned a value indicating that the submit failed.

    What can be the cause of that?

    I figured out how to change the names, but not like the example on page 8. I went back to sharepoint and renamed the colums, renamed labels in the xml file, modifyed the connection in my infopath file,saved and reopned, and Voilá, the names are looking good.

    Best regards


  • Hi Troels,

    Are you using the "Submit" event of the "click" event of a button to execute the code? If you are using the "submit" event make sure you have a line of code like this for when it is successful:

    e.CancelableArgs.Cancel = false;

    If not, post your code and I'll take a look.


  • Hi scott

    The code is the excact one you posted on page 13. I dont get any error messages any more after the submit code you mentioned was enabled, but no data is transferred to Sharepoint?. When I look at the code I cant se any connection to the sharepoint list, is that correct?

    Best regards


Page 27 of 36 (530 items) «2526272829»