Submitting to a SharePoint List


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>
    </Method>
</Batch>


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

Comments (559)

  1. Matt Faus says:

    Thanks for this fancy reiteration of my post!  However, since people have been doing this for over a year now, I think a more helpful post would be on how to get this form to look good.  The schema does not allow for very easy representation with standard InfoPath controls.  We have discussed possibilities for solutions to this problem in our forums, but an elaborate (and codeless) example form would be stupendous!

  2. Gerhard_Moschner says:

    Any ideas how to integrate a dropdown list for any of the sharepoint list fields in the form?

  3. Scott Heim says:

    Hi Gerhard,

    I am not sure I follow your question. For instance, what I can do is simply add another data connection to the same list and use this connection as the source of values for the dropdown list boxes – does that help?

    Scott

  4. Scott Heim says:

    Hi Matt,

    Thanks for your suggestion and again – thank you for the original post!

    Any way I can ping you offline about your request?

    Scott

  5. techietex says:

    Hi Scott,

    Thanks for the article. I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list. Do you know what I might be missing here?

  6. Scott Heim says:

    Hi – off the top of my head, the first thought is if you have the correct GUID specified for your list?

    Scott

  7. techietex says:

    well, found the solution. I wrote a windows app to submit data to the same list I was trying earlier and that gave me the required error message.

    I was getting:

    The list or view of the list referenced here no longer exists.

    found the solution to that in this KB article:

    http://support.microsoft.com/kb/840549

  8. Scott Heim says:

    I am glad you found the cause of the problem!

    Scott

  9. This weekend I took some time to research and then test methods to post information from an Infopath

  10. iota says:

    Hi Scott,

    My english is very poor! I think you will very difficually to understand the meaning for this quote :>

    My problem is look like techietex.

    I can submit the form and show the successful message. But the target list can not be update any information.

    I double-checked the default GUID value in the ListName and sure this GUID as same as the traget list.

    Do you have any idea ??  Waiting for your reply.

    Iota

  11. hesg says:

    Hi!

    I’m experiencing the same problem as iota and techietex. When I’m submitting my form I recieve a message that tells me that the data has been posted successfully. But of course, no item in the list.

    I checked the GUID three times just to make sure. And I tried creating a new Team Site with a new List that the form could post to, but still the same result.

    It’s really strange…

  12. doubter13 says:

    Same thing here, double checked everything and tried it on two different sharepoint systems.

    I do get the message that everything was submitted, but nothing appears in the list. Any suggestions?

  13. doubter13 says:

    OK, solved the Problem.

    Somehow the GUID changes after the creation. I created the List, checked the GUId and tried it with that ID, with no success, then i added something to that list and rechecked the GUID and got another one, after trying again with that GUID it worked.

  14. iota says:

    Hi Doubter13,

    I tried your solution in the last time but not successfully. Do me a favor, can you check some configure in your form and SP server as the following ?

    1) Which type are you selected for your site ?

    e.g. Document Library, Form Library, Custom List etc.

    2) Do you define the ID field in the XML file ?

    e.g. <Field Name = ‘ID’></Field>

    3) Would you please to check the DCOM services status in your IIS server ? I found the error messages for this in the Event Viewer – System. Please see the error detail as the following.


    Event Type: Error

    Event Source: DCOM

    Event Category: None

    Event ID: 10016

    Date: 4/24/2007

    Time: 4:31:10 AM

    User: NT AUTHORITYNETWORK SERVICE

    Computer: ABCDE

    Description:

    The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID {73738744-F397-33D0-9953-00C04FD939C3} to the user NT AUTHORITYNETWORK SERVICE SID (S-2-3-45).  This security permission can be modified using the Component Services administrative tool.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


    Are you happen this problem in your server ?

    Thank you for your Help.

    IOTA

  15. Scott Heim says:

    Hi everyone,

    Sorry for the delay in responding – I have been out of the office for the last week.

    Doubter13 – glad to hear you have resolved the issue! For everyone else, a couple of points to check:

    • If you have renamed the "Title" field to be your own name, the CAML query will still need to reference that field as "Title."
    • Check the Application Event log and see if there are any errors or warnings when you test this process – we could be hitting a permissions issue based on the Application Pool Identity Account being used in the Application Pool for your site

    Scott

  16. cidras says:
    • hi, Scott,  doubter13

    I try checked GUID for my list. They are correct but  no items add to my list. Please, help me. Thanks

  17. Scott Heim says:

    Hi doubter13,

    I thought you had this resolved? Have you renamed the "Title" field in your list? Are there any errors or warnings in the Application Event log or the server log?

    Scott

  18. Snaap says:

    Hi guys,

    Could you please help David (galetarconsulting.com) out, he posted a desperate message on my blog because I linked to this article, but he didn’t know how to drop a comment here, or to get in contact with you all (I guess there’s a need to register and login?). Anyway, here are his questions:

    In section #3, it says:

    "1. Create a new, blank, browser-compatible form template"

    • What does it mean by this?
    • How do I do this?

    In the same section it says:

    "2. Add a “Receive” type secondary data connection to the Add List Item Template.xml file created in Step #2.", and "3. Add a “Receive” type secondary data connection to the “MyContacts” SharePoint List created in Step #1"

    • What does it mean by this?
  19. How do I do this?

  20. Lastly, I need to place this form on the companies "Public" portion of the website (for anyone to fill out), while I collect the data in a "Private" part of the website, or the "Sharepoint" part of it.

    PLEASE HELP- – – I WOULD REALLY APPRECIATE IT!!!!!!!!!

  • Scott Heim says:

    Hi,

    1. Create a new, blank browser-compatible form template

          – Launch InfoPath

          – Click Design a Form Template

          – Choose Blank and enable the option: "Enable browser-compatible features only"

    2. You add data connections to an InfoPath Form Template by selecting Data Connections from the Tools menu and clicking Add. There you can choose whether the connection type is Submit or Receive

    3. This is going to be challenging as I am assuming the "public" site is going to allow Anonymous Access. If so, then SharePoint security is designed to not allow any submissions to a library or list with Anonymous access enabled. As such, this process will change as the data will need to be submitted to a custom web service that you create to take the XML and create the list item for you.

    Scott

  • cidras says:

    I got items in my list (used file XML and GUID of my list). But I not add item in my list (used web service of sharepoint).

    Please, help me.

  • Scott Heim says:

    Hi Cidras,

    If none of the other suggestions in these comments have been of benefit, then the best option would probably be a support case with Microsoft Product Support Services so this can be looked into further.

    Scott

  • cidras says:

    yeah, I added item in my list. Thank you, Scott.

  • ramkumar1910 says:

    Am I missing someting?

    Shouldnt we just add Lists.asmx as the datasource and pass the SPquery? Why do we have to do CAML?

  • fbrum says:

    I everybody!

    I’m a newbi on both Sharepoint and Info path.

    I have a question.

    In the xml template, is it possible to refer a field that in the sharepoint it’s a Choice (menu to choose from), that is acombo-box.

    If so, than how?

    Thanks in advance for the attention.

  • hi fbrum,

    Hope this solves your problem 🙂

    i have added a combo box name folderName and another text box named txtFolderName.

    Whenever the selection changes for the combo box i am reading the value into the text box.

    i have added manged code handler to the changed event of combo box … (please note you will require VSTA installed onyour pc in order to add a .net code to your Infopath form)

    public void folderName_Changed(object sender, XmlEventArgs e)

           {

               // Get reference to the root node.

               XPathNavigator root = this.MainDataSource.CreateNavigator();

               //Get the reference to the text box.

               XPathNavigator text = root.SelectSingleNode("/my:myFields/my:txtFolderName", this.NamespaceManager);

               //Get the selected value into text box.

               text.SetValue(root.SelectSingleNode("/my:myFields/my:folderName", this.NamespaceManager).Value);

    }

    combo box is prepopulated by reading a list items in my sharepoint server….

    just go through the code,  its simple XML reading nothign else…

    revert back to me if you need any info 🙂

    hope this is what you were looking for…

    Regards,

    Sudhir

  • fbrum says:

    Thanks!

    That does clear things out. 🙂

  • apersson says:

    Hi,

    Is it possible to modify the procedure to submit the entire form to a forms library?

    I know you can submit directly to a forms library, but we have a scenario with anonymous users and since we can not grant anonymous users write priviliges to libraries we need a method of submitting via a web service.

    Cheers

    apersson

  • Scott Heim says:

    Hi apersson,

    Here is a "sample" web service method for creating a new InfoPath XML file in a SharePoint library. To use this, you would:

    • Create a new Submit data connection in InfoPath
    • Point the "fileName" parameter to a node in your data structure (obviously you could hard code this as well)

    • For the "fileContents" parameter you will choose "Entire form" and then enable the option: "Submit data as string"

    [WebMethod]

       public void CreateInfoPathDocument(string fileName, string fileContents)

       {

           try

           {

               string pathFolder = "SubmitViaWebService"; //Where the form will be created

               SPSite site = new SPSite("http://server&quot;);

               SPWeb web = site.OpenWeb();

               SPFolder folder = web.Folders[pathFolder];

               if (fileName.IndexOf(".xml") == -1)

                   fileName += ".xml";

               string fileUrl = folder + "/" + fileName;

               System.Text.Encoding e = System.Text.Encoding.UTF8;

               byte[] b = e.GetBytes(fileContents);

               SPFile file = folder.Files.Add(fileUrl, b, true);

           }

           catch (System.Exception ee)

           {

               throw new ApplicationException(ee.Message);

           }

       }

  • apersson says:

    Thanks Scott,

    Thank you for your fast reply.

    So this can’t be done without coding?

    Cheers

    apersson

  • Scott Heim says:

    Hi,

    Well – as you have seen, if anonymous access is enabled that anonymous user cannot submit directly to SharePoint. As such, you will need to create a custom web service to handle the submit and create the form – so no – there is no way (that I know of <G>) to do this without writing custom web service code.

    Scott

  • apersson says:

    Hi,

    Yes, I understand that, I just figured that the lists.asmx web service could be used.

    🙂 Actually, I think the major problem isn’t that anonymous users can’t submit to a library. I think the major issue is that for anonymous users to submit to a list you have to give them view priviliges as well.

    Cheers

    apersson

  • iceeicee24 says:

    Hi Scott,

    I tried to follow all the steps you mentioned and encountered no error but when i started to submit the form, i am recieving the following error:

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.

    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring></detail>

    How am i gonna solve this? Please advise.

    Thanks,

    icee

  • Scott Heim says:

    Hi icee,

    Did you try the exact steps I documented? I have not seen this specific error before regarding this process so the first thing to make sure of is that you are following the exact steps – no changes. Then once this sample is working, move forward with your actual scenario.

    Scott

  • IHunter says:

    This tutorial worked for me.  The one thing I ran into and corrected is when setting up the webservice on a teamsite the servername in the following example must contain the full path to the team site you want to create this webservice for.

    http://servername/_vti_bin/lists.asmx

  • IHunter says:

    I do have a question though.  In this tutorial you’re only using a CAML template, which is only allowing me to use a repeating table.  The repeating table is the exact format as the list form on sharepoint which I’m trying to break away from.  

    Is there any way to design a form the way you want and have the fields send to a sharepoint list.  and if not is there any way to have a form update the fields in the CAML list so I don’t have to comprimise the look of my form?

  • iceeicee24 says:

    Thanks scott and hunter,i think i made a mistake in the url of the web service, now it submits successfully, thanks

  • darryl2912 says:

    Hi Scott,

    When I hit the Submit button I get the following error. I have followed the exact steps as what is in the blog. Can you please urgently help me with this matter.

    The error is:

    The data connection MyContacts is using a URL: http://auperadev03:82/sites/ChangeControlPortal/ChangeControlDev03Site/Lists/MyContacts/AllItems.aspx

    The error I am getting is as follows:

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.

    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">There is no Web named "/sites/ChangeControlPortal/ChangeControlDev03Site".</errorstring></detail>

    Kind Regards

    darryl2912

  • darryl2912 says:

    Hi Scott,

    I figured this one out.

    …Sorted this now….I was selecting the list service of the root site instead of the sub site……

    darryl2912

  • darryl2912 says:

    Hi Scott

    In submitting the InfoPath form according to your blog, which I now have got it to work I want to be able to also submit with that form an attachment. Do you know how to do this using the CAML approach that you had used in your blog. It must be possible but I do not know how to. Any other blogs or have you got a solution for this as well. What can I place in the xml to get it to work. This would be very handy for us.

    Kind Regards

    darryl2912

  • zullu says:

    Hi Scott Heim,

    I have a problem when submitting a infopath form to a doc library. I am a newbie, tried to follow the steps defined in thw url:

    http://articles.icscentral.com/Kb%20Articles/274/826993.aspx

    But when I test my form, I get an error:

    "InfoPath cannot submit the form.

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

    When I tried debugging the code, I found error is generated on line: [oXmlHttp.Open("HEAD", strUrl, false;]

    and by placing the code below in the Catch(ex) section

    XDocument.UI.Alert(ex.message);

    XDocument.UI.Alert(ex.number);

    I get the message as "Permission denied". The error number returned is "-2146828218".

    Any clue as to why is this happening.

    I have even given full control acess to the site and have created a "Test" Doc Lib so my strUrl is "http://oss1/sites/PnP/Test/testform.xml&quot;

    Thanks for any help.

    zullu

  • infopath says:

    Hi darryl2912,

    I am been testing functionality to include an attachment but have not been 100% successful. When I have some time to work on this, I will look at it again and if successful, will modify this post.

    Zullu,

    Based on the error, it seems you still have a Permissions problem. Try creating a submit connection in the InfoPath UI to the same library…can you submit without any error?

    Scott

  • chirag65303 says:

    I can view the List Item Data in Infopath form as well I can Add the New List Itsm in Sharepoint List through this code. Its working fine.

    I am looking for the updating existing list Itmes data through this UpdateListItem web service but not able to get through…

    plz look in to it..thanks

  • gorpade says:

    Thanks for the article. I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list. Do you know what I might be missing here?

    Thanks for any help?

  • infopath says:

    Hi gorpade,

    Have you reviewed the comments in this post to see if any of them help? A number of folks have received this same behavior and were able to resolve the problem. Make sure the list service you are calling is for the appropriate site.

    Scott

  • infopath says:

    Hi zullu,

    Have you looked at the Application Event Log or the Server logs to see if there are more details to the error? Is this a browser form? If so, you will probably need to change the logging options to Verbose for the Forms Services logging operations.

    Scott

  • nataliediem@gmail.com says:

    How would you handle a repeating table/section with the SharePoint list?  

  • infopath says:

    Hi ndiem,

    I have not tried this but just off the top of my head, you could use code to enumerate the nodes in your repeating table and execute the web service/CAML directly.

    I don’t know that there is a way to do this without a custom code procedure.

    Scott

  • kaj says:

    How would you write code to enumerate the nodes in a repeating table and then execute a web service?

    Can you point me to any samples or tutorials?

    Thanks.

  • infopath says:

    Hi kaj,

    Here is some sample code I wrote to simply enumerate the existing contacts returned from the list and subsequently update those same contacts with the new values entered in the table. You could use this as a basis for how to accomplish what you need:

    public void CTRL26_5_Clicked(object sender, ClickedEventArgs e)

           {

               //Create a new instance of our "Lists" web service

               server.Lists myList = new SubmitToSharePointList.server.Lists();

               //Pass the logged on users credentials to the web service

               myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

               //myList.Credentials = new System.Net.NetworkCredential("user", "password", "domain");

               //Create a DataSource object for our list data source

               DataSource dsContacts = this.DataSources["MyContacts"];

               //Create a Navigator object so we can enumerate the list

               XPathNavigator xnContacts = dsContacts.CreateNavigator();

               //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

               XmlNamespaceManager ns = this.NamespaceManager;

               //Create a NodeIterator object to enumerate all of the existing contacts

               XPathNodeIterator xi = xnContacts.Select("/dfs:myFields/dfs:dataFields/dfs:MyContacts", ns);

               //Enumerate each existing contact and update the values in each record with the changed information

               while (xi.MoveNext())

               {

                   //Create XPathNavigator objects for each field from our list

                   XPathNavigator xnID = xi.Current.SelectSingleNode("@ID", ns);

                   XPathNavigator xnFirstName = xi.Current.SelectSingleNode("@FirstName", ns);

                   XPathNavigator xnLastName = xi.Current.SelectSingleNode("@LastName", ns);

                   XPathNavigator xnTitle = xi.Current.SelectSingleNode("@Title", ns);

                   XPathNavigator xnEmail = xi.Current.SelectSingleNode("@Email", ns);

                   XPathNavigator xnPhone = xi.Current.SelectSingleNode("@Phone", ns);

                   //Create a new XmlDocument to use for specifying the Update CAML query

                   XmlDocument doc = new XmlDocument();

                   //Create the needed update element

                   System.Xml.XmlElement updates = doc.CreateElement("Batch");

                   string strOperation = "Update";

                   //Create the CAML query passing in the value of each of our fields from the form

                   updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’" + strOperation + "’>" +

                   "<Field Name=’ID’>" + xnID.Value + "</Field>" +

                   "<Field Name=’FirstName’>" + xnFirstName.Value + "</Field>" +

                   "<Field Name=’LastName’>" + xnLastName.Value + "</Field>" +

                   "<Field Name=’Title’>" + xnTitle.Value + "</Field>" +

                   "<Field Name=’Phone’>" + xnPhone.Value + "</Field>" +

                   "<Field Name=’Email’>" + xnEmail.Value + "</Field>" + "</Method>");

                   //Update the list

                   XmlNode node = myList.UpdateListItems("EAD1852F-6884-47B0-B928-BCB167698784", updates);

                   dsContacts.QueryConnection.Execute();

               }

           }

  • presack says:

    Excellent work Scott (and Matt).

    I am a beginner.  I got the demo working but have a couple of questions.

    I would like to essentially implement the solution you have done, except with two changes:

    1)  I would like the ability to customize the look of the form some more, which has been mentioned elsewhere in the thread, including by Matt.  So I assume there is nothing new in that regard and will continue monitoring this and other forums.

    2)  I would like to be able to do this with a document library.  Everything I find seems to be on how to submit the actual form to the library.  What I am attempting is a little bit different from the examples I have found- I want the user to be able to browse to a file to upload to the document library (just like in Sharepoint), to collect all of the other fields I need just as in your list example, and then click submit to create a new entry in the document library with the "browsed-to" file as the file in the document library.

    FYI- The reason for doing this instead of just the Sharepoint add, in our case, is so I can gain some more control (and provide choices from some different data sources) for their selections for the other columns that will ultimately describe the document.

    I hope that makes sense.  Thanks in advance.

    presack

  • infopath says:

    Hi presack,

    Agreed – it would be nice to have a re-design of the form but I just have not had time to think about this much – sorry.

    Regarding your 2nd question – is your form designed for the browser for for the client?

    Scott

  • presack says:

    Thanks for the response, Scott.

    No problem on point one- that’s what I figured.  I am not far enough along right now in my experience (thus the novice post) to develop a way myself yet.

    I am currently planning on using the browser-enabled form, but using the client is an option in our environment.  All users have InfoPath 2003 SP1.

    Thanks,

    presack

  • infopath says:

    Hi presack,

    If your preference is a browser form, you may want to look at using a custom ASPX page with the XmlFormView control. This way you can easily provide an option to allow your users to "browse" for a file to upload.

    Then you could create a web service on your SharePoint server that uses the SharePoint Object Model functionality to grab the selected file and upload it to the appropriate document library. I don’t have any sample code on this but you should be able to search around and find something – maybe on a SharePoint BLOG.

    Here is a link to using the XmlFormView control:

    http://msdn2.microsoft.com/en-us/library/aa701078.aspx

    Scott

  • presack says:

    Thanks again.  That looks like a potentially workable solution.  Another article I found that may be of interest to people in this thread (although it is not an Infopath solution- sorry!) is below:

    http://msdn2.microsoft.com/en-us/library/ms916819.aspx

    It provides the ability to customize Sharepoint List forms (both the input and the display).  It looks to me like it has some drawbacks, but I’m not in a position right now to have the time to implement it.  I just thought it was worthy of note.

    presack

  • Giannis says:

    Hi,

    I try to complete the “Submitting to a SharePoint List” but I have the same problem that read in your comments “When I’m submitting my form I recieve a message that tells me that the data has been posted successfully. But of course, no item in the list.”. I checked everything again and again but the problem remains. I try the example with Contact List of MOSS (Parent example from Matt Faus) and works (needs a simple change on GUID and Submit button). I try to create my own list (in same site and area with contact list) and run the example but the result was dishearting. I check the settings of two lists (mine and contacts)no difference except field “Title” that included only in my list. Did anybody knows the reason?

    Giannis

  • Giannis says:

    Hi Scott,

    in an template example that you given at June 18 to kaj you use

    "server.Lists myList = new SubmitToSharePointList.server.Lists();"

    I try it but I cann’t find the assembly reference. An idea please.

    thanks for your help.

    Giannis

  • mavsguy842 says:

    Hey all,

    I’ve followed all of the steps in this example and am getting everything to work perfectly except:

    I need to have this form be browser-enabled so that clients without InfoPath can fill out the form and thus populate a SharePoint list without ever being directed to the List’s actual add item page.

    When starting the template I enabled browser enabled features only, so I figured this wouldn’t be a problem, but it seems to be.  The design checker tells me "Invalid form Template" and the detail box says "An unexpected error has occured while verifying the form template."

    I’m wondering if this might be a problem with how Forms Services is configured on the server, or any other suggestions you might have.  

    Thanks,

    Matt Callaway

  • ishayb says:

    Hello,

    How can I create initially automatic file name when the user clicks on "submit" button (at web InfoPath on the ribbon area)?

    Tools-> submit options-> to SPS ’07

    Sample: "file_" + now() + userName

    Thank for original post.

    Ishay

  • UKaren says:

    Hello,

    may be you can give me a hint how to do this:

    I can insert new items to the list as long as I don’t use a field that contains a Person/Group-Field. I think, I need a GUID or something like this for the person-Field – but where can I get the information from?

    I tested with a GIUD-like value I got from the webservice:

    userprofileservice.asmx – GetUserProfileByName. But this doesn’t work.

    Any idea what’s correct?

  • infopath says:

    Hello everyone,

    My apologies for the delay in responding.

    For Giannis:

    For Matt Callaway:

    • Have you been able to resolve this issue? When I developed this sample, it was with browser-compatibility enabled so this should work without issue. Let me know if you are still experiencing a problem.

    For Ishay:

    • You will want to use the "concat" function to concatentate text, functions and/or field names.

    For UKaren:

    • The only way I have been able to accomplish this (adding a new item with a Person/Group field) is to use code to insert the new item. I tested this with the "Tasks" list and was able to use the Contact Selector control on the form to allow the user to select a person. I then use a custom .NET web service to open the appropriate "web", create an "SPUser" object and return the "ID" of that user. This is what I finally use to set the "AssignedTo" field.

    Thanks everyone for your patience!

    Scott

  • ishayb says:

    Hello Scott,

    My scenario is:

    After I Open a web infopath form and complete all input fields then I submit the new form.

    now the form is save automatic in sps list


    How can I Generate a unique identifier  prameter when i create new item on infopath automatically ?

    (mynane + unique_id() -> save automatically into sps list)

    T U

    IshayB

  • infopath says:

    Hi Ishay,

    There are a number of ways to create a unique ID:

    • Use a data connection to a database that increments a number and returns that to you
    • Use a web service that does something similar, etc.

    There is not a built-in way to get the unique identifier from SharePoint since this does not get assigned until after the form has been submitted.

    Probably the easiest method is to either use a web service that gets the next value from a database or, if you are already using code in your form, you could generate a GUID value and add this to your form name.

    Scott

  • UKaren says:

    Hi Scott,

    thanks for your answer. It works fine.

    It helped me to find the following:

    Use Webservice UserGroup.asmx – GetUserInfo

    The result contains an ID and Name-Node.

    Concat them to a string like ID;#Name. This is what you have to paste to the field you want to update. This works as well for groups. Use GetGroupInfo instead.

    Another problem:

    The name of the column "Assigned To" in the tasklist has a blank in its name. I haven’t found a way to update columns with a blank in its name (whatever datatype they have). Any idea how to overcome this?

    There are lots of columns coming from Microsoft with blanks and I don’t want to customize them every time…

  • infopath says:

    Hi UKaren,

    I am not sure I follow what you mean by a "blank" in its name. How are you determining this? When I go to my Tasks list and click New, I see the AssignedTo field but when I click in that field I don’t have a blank.

    Sorry if I am missing something obvious.

    Scott

  • UKaren says:

    Hallo Scott,

    sorry – for my bad english. on all sharepoint-server I have access to the column name of the AssignedTo field is written as "Assigned To" – between Assigned and To there is a character (Ascii 32). That’s what I call "a blank".

  • infopath says:

    Hi UKaren,

    Thank you for the clarification – now I understand!

    In actuality, when you are setting the "Assigned To" column to a value, the underlying column name is "AssignedTo". This appears to be true of most, if not all, of the column names. Even though they show spaces, the actual names do not contain a space.

    For instance, "Start Date" is actually "StartDate", "Workflow Name" is "WorkflowName".

    If you ping a SharePoint Blog you may find a better way to determine this – I use this tool:

    http://www.sharepointblogs.com/mossman/archive/2007/04/11/u2u-caml-query-builder.aspx

    Please note this is not a recommendation – merely a tool I use to help build the CAML queries since I am not a SharePoint expert! 🙂

    Scott

  • realminds says:

    UKaren, u can use SharePoint Explorer (latest version which support MOSS 2007) to see the actual values of field names.

  • Giannis says:

    Thank you Scott,

    Sorry am late to answer you. I have already find the way to do what I asked.

    I apologies that I thought  what you write in your example  I must type it as is. I understand later the changes.

    Thanks again.

  • infopath says:

    Hi Giannis,

    That is great to hear! I am glad it is working for you now.

    Scott

  • realminds says:

    Hi,

    Following can be used to get the Unique UserID to be passed in "Assigned to" in the task list.

    Private Function sGetUserID(ByVal sUserID As String) As String

               Dim strUserID As String = ""

               Dim ugp As New WSUG.UserGroup()

               ugp.Credentials = New NetworkCredential("User", "Pwd", "Domain")

               Dim NDUser As XmlNode = ugp.GetUserInfo(sUserID)

               Dim xnrUserInfo As XmlNodeReader = New XmlNodeReader(NDUser)

               While xnrUserInfo.Read()

                   If xnrUserInfo.Name = "User" Then

                       strUserID = xnrUserInfo.GetAttribute("ID")

                   End If

               End While

               Return strUserID

           End Function

  • mavsguy842 says:

    Scott,

    Thanks for getting back to me.  Through much more extensive testing of many different scenarios/forms I’ve come to believe something is wrong with the installation of my Forms Server.  Even when I create a simple form with only one text box I receive multiple errors:

    1) When publishing, InfoPath says that the form will not be able to be opened from within a browser – "Invalid Form Template."

    2) "Unknown Error" on the SharePoint site when attempting to Create New from within the form library.

    3) "Unknown Error" on the SharePoint Server when attempting to upload a form directly to the server (not by publishing).

    If you have any suggestions I’ll take them, but I’m pretty sure this is NOT a problem with your example.

    Thanks,

    Matt Callaway

  • smacky311 says:

    I tried publishing this completed form as a browser enabled content type.  The form will launch, but it will not submit.  I get an error when I hit submit and the list does not update.  I have even added some custom code I found online and have been unsuccessful in making this form work in a browser.  Has anyone been able to do it?  

    Regards,

    Brian

    -To be clear, the form works perfectly fine when launched from inside the Infopath client, but not from the browser enabled infopath form setup as a content type in a document library.

  • infopath says:

    Hi Brian,

    I just tested this process after pubishing my XSN as a Site Content Type and it worked from the browser without issue.

    If you would, try these steps:

    • Delete the Content Type from the document library where you added the published content type
    • Delete it from the Site Content Type list

    • Delete the XSN from the saved location

    • Create a new library on the same site called: ContentTypes

    • Publish the XSN as a Site Content Type and save it in the ContentTypes library

    • Add it as a Content Type to your document library

    • Test

    Scott

  • Deniz Yalman says:

    Hi Scott,

    I am trying to allow anonymous users to submit items to Sharepoint List using "Infopath Form Services" over the browser, but I am facing some issues.

    In order to achieve this, I have created a web service as you have explained in here:

    http://blogs.msdn.com/infopath/archive/2007/03/26/submitting-to-a-sharepoint-list.aspx#2969087

    I can submit the form through infopath as "string as data", but when I try to submit it using form services over the browser, it fails returning an error: "Infopath cannot submit the form".

    Are anonymous users not allowed to add items to sharepoint list using infopath form services?

    Also, can this issue (allowing anonymous users to add items to sharepoint list through form services) be overcome with another method?

    Thanks in advance

  • infopath says:

    Hi Deniz,

    Chances are this is a login/permissions issue. When you use the InfoPath client you are coming in as that logged on user; however, when using the browser you will be trying to create the form as the identity specified in the Application Pool for your site.

    Have you taken a look at your server logs? Reproduce the error, then open the latest server log, scroll to the bottom and then do a search "up" for Forms Services – you will probably find an error regarding authorization, permissions, etc.

    Scott

  • yannis says:

    Regarding the "Invalid property name", "Duplicate property name namespace in file schema.xsd" error messages, I have got over them by removing a "<xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace&quot; processContents="lax"/>" reference that I found in the schema.xsd file.

    After you remove this reference, do not forget to "Convert Main Data Source" with the new schema file and check that your data source is intact.

  • ghodnett says:

    Hi there,

    This post has helped me a lot, but I can’t figure out how to retrieve and update a specific list item. I need to be able to click a link in a sharepoint item list, that will open the Infopath form used to edit that item and do the necessary processing, and then save the changes to that specific item.

    It sounds like it should be easy enough!

    Thanks,

    Garth

  • infopath says:

    Hi Garth,

    Unfortunately it is not as easy as it may seem. The only way I have found to do this is to custom code because you need to be able to modify the CAML query to tell it what type of edit you are doing (i.e. New, Delete, etc.) and then for which item in the list.

    Using the steps in this sample, I have modified the table structure returned from the list to add a new column. This column simply holds a button that would be used to "update" the data in that row. Here is some sample code that I have used to accomplish this:

    • On the click event of this button, I have just this code:

    UpdateList("Update", e.Source.CreateNavigator());

    • Here is the "UpdateList" procedure:

    public void UpdateList(string strOperation, XPathNavigator e)

           {

               //Create a new instance of our "Lists" web service

               serverName.Lists myList = new serverName.Lists();

               //Pass the logged on users credentials to the web service

               myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

               //Create a DataSource object for our list data source

               DataSource dsContacts = this.DataSources["MyContacts"];

               //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

               XmlNamespaceManager ns = this.NamespaceManager;

               //Create XPathNavigator objects for each field from our list

               XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

               XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

               XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

               XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

               XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

               XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

               //Create a new XmlDocument to use for specifying the Update CAML query

               XmlDocument doc = new XmlDocument();

               //Create the needed update element

               System.Xml.XmlElement updates = doc.CreateElement("Batch");

               //Create the CAML query passing in the value of each of our fields from the form

               if (strOperation == "Delete")

               {

                   updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Delete’>" +

                   "<Field Name=’ID’>" + xnID.Value + "</Field>" + "</Method>");

               }

               else

               {

                   //Create the CAML query passing in the value of each of our fields from the form

                   updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Update’>" +

                   "<Field Name=’ID’>" + xnID.Value + "</Field>" +

                   "<Field Name=’FirstName’>" + xnFirstName.Value + "</Field>" +

                   "<Field Name=’LastName’>" + xnLastName.Value + "</Field>" +

                   "<Field Name=’Title’>" + xnTitle.Value + "</Field>" +

                   "<Field Name=’Phone’>" + xnPhone.Value + "</Field>" +

                   "<Field Name=’Email’>" + xnEmail.Value + "</Field>" + "</Method>");

               }

               //Update the list

               XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

               XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

               //Requery the data source to reflect the updates

               dsContacts.QueryConnection.Execute();

           }

    As you can see, this code can also handle a "Delete" submission as well.

    Scott

  • ghodnett says:

    Hi Scott,

    Thanks for the reply! How do I open an Infopath form, from a Sharepoint list item (e.g. by clicking on an icon)? I assume I can put the form into a Sharepoint webpart? And, is it possible to pass a parameter to that form, that I can use in one of it’s fields?

    Thanks,

    Garth

  • infopath says:

    Hi Garth,

    Not sure I follow the first question…are you asking how to click on a SharePoint list item and that will open an InfoPath form? If so, I am not sure how you would accomplish this – a Content Query Part may be the answer.

    In regard to the parameters question, take a look at this blog post:

    http://blogs.msdn.com/infopath/archive/2007/02/26/passing-data-into-a-form-input-parameters.aspx

    Scott

  • ghodnett says:

    Hi Scott,

    Perhaps I’m approaching my problem in the wrong way. Basically, I’ve got an employee list that shows where employees are, when they left and when they will be back. An employee needs to be able to click on an icon in their line that will open a form that allows them to select a location and a time of return and this must also start a workflow. Currently I am doing this using content types – the employee clicks on the edit icon that opens a content type that allows them to either select a location with a specific time, or to enter a location and return time. This was easy to and works, but it does not give me the flexibility to do all the processing that I need to (the processing that I need to do is very basic, but I find have to use multiple calculated fields rather than a few lines of code). That’s why I was thinking of opening an infopath form from the line. But maybe you could suggest another way?

    The problem is that,although I am a developer, I don’t know much about web development, Sharepoint or .net. Is there a way to put code on the sharepoint fields, like I could put code on SQL field? I feel a bit frustrated because I know the logic I need to apply, but I don’t know where to put it!

    Thanks,

    Garth

  • infopath says:

    Hi Garth,

    Unfortunately, I am not a workflow expert. In fact, with the group I am with (InfoPath support) we see very little of the workflow issues as they are primarily handled by our SharePoint folks (at least from an Office workflow perspective.)

    I don’t mean to dance around your question but I don’t want to steer you in the wrong direction. Have you seen the SharePoint/Workflow blog: http://blogs.msdn.com/sharepoint/archive/tags/Workflow/default.aspx ?

    You may want to post here and see if you can get some better direction.

    Now, what I am wondering is this: you mentioned that you are currently doing this with "Content Types." You can certainly publish an InfoPath Form Template (XSN) as a Site Content Type as well. Without knowing exactly how you are launching the content types, I wonder if this would provide any benefit? With this being an InfoPath Form Template simply published as a Content Type you can certainly manipulate the data the same way as if you published the form as any other type.

    Scott

  • mpang says:

    I am new to InfoPath.  I tried this and it worked perfectly.  Can you elaborate on your response dated in April about integrating a dropdown column in a sharepoint list with infopath? It would be great if you could list the key steps.  Thanks!

  • infopath says:

    Hi mpang,

    What I was referring to in my response was adding a secondary data connection in your InfoPath Form Template (the XSN file) that was a connection to a SharePoint list. You can then use that connection as the source of data for your dropdown box in your InfoPath file.

    However, if what you are asking is how to consume a "Choice" type of column from SharePoint in your InfoPath Form Template there is no direct way for this in InfoPath.

    Scott

  • infopath says:

    Hi jrk555,

    Here is sample code that I just tested that works for me – obviously I am just hard-coding some values but try this and see if it works for you. This is the code I have in the click event of a button:

    //Create a new instance of our "Lists" web service

    server_Lists.Lists myList = new SubmitToSharePointList.server_Lists.Lists();

    //Pass the logged on users credentials to the web service

    myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

    //Create a DataSource object for our list data source

    DataSource dsContacts = this.DataSources["MyContacts"];

    //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

    XmlNamespaceManager ns = this.NamespaceManager;

    //Create a new XmlDocument to use for specifying the Update CAML query

    XmlDocument doc = new XmlDocument();

    //Create the needed update element

    System.Xml.XmlElement updates = doc.CreateElement("Batch");

    //Create the CAML query passing in values

    updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’New’>" +

    "<Field Name=’FirstName’>ABC</Field>" +

    "<Field Name=’LastName’>DEF</Field>" +

    "<Field Name=’Title’>EE</Field>" +

    "<Field Name=’Phone’>980-555-1212</Field>" +

    "<Field Name=’Email’>abc@hotmail.com</Field>" + "</Method>");

    //Update the list

    XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

    XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

    //Requery the data source to reflect the updates

    dsContacts.QueryConnection.Execute();

    I would try this with a new form and even go so far as to hard code the field values and the list GUID – this way you can take all variables out of the picture and see if you can get this to work.

    Scott

  • jrk555 says:

    Hi Scott,

    Thanks for taking time to check on it.

    I resolved the issue i am having. When we add a web reference to the lists web service, we need to include ?wsdl at the end. So it has to be something like http://server/site/_vti_bin/lists.asmx?WSDL.

    I didnot include that initially. I included that now and its working fine.

    Appreciate your help and thanks for posting this article.

    -jrk555

  • infopath says:

    Hi jrk555,

    Excellent! Glad you have this working…

    Scott

  • indiarocks says:

    Hi Folks,

    I have followed the exact steps as mentioned above but i am getting the message "The form was submitted sucessfully" but actually the item is not added into the list. I have ensured the correct GUID. I can see that many people have faced the same problem so hoping to get the exact solution of this problem…

    Hope to get the response soon.

    Thanks and Regards,

    S

  • indiarocks says:

    Hi Guys,

    Could anybody reply me about my problem? I will appreciate if someone could. I am stuck with that as i am not able to inserting item into list even after following the above steps…

    Thanks a lot in advance…

    My mail id is software.sanjay@gmail.com

    Thanks,

    Sanjay.

  • infopath says:

    Hi Sanjay,

    Make sure you are referencing the correct "Lists.asmx" web service. For instance, if your list is at http://server/lists/list_name then the web service you will want to use is http://server/_vti_bin/lists.asmx; however, if your list is at http://server/site/lists/list_Name then the web service you need to use is http://server/site/_vti_bin/lists.asmx.

    Scott

  • infopath says:

    Hi Sanjay,

    Please excuse my lack of SharePoint knowledge here…but have you tried:

    http://servername/SiteDirectory/SanjaySite/_vti_bin/lists.asmx

    Scott

  • indiarocks says:

    Hi Scott,

    There is no lists.asmx file at the URL http://servername/SiteDirectory/SanjaySite/_vti_bin/lists.asmx

    Thanks and Regards,

    Sanjay Patel.

  • infopath says:

    What is "SiteDirectory" in your URL? Is that a site or something else? For instance is http://servername/SanjaySite the same as http://servername/SiteDirectory/SanjaySite?

    Scott

  • shakes11 says:

    Hi Scott,

    Since it is not possible to rename the "Title" field in the CAML file, is there a way to hide it? I would like to create an InfoPath form that links to an existing list and I would like for users not to see the "Title" field when they fill it out.

    Greatly appreciated!

  • infopath says:

    Hi shakes11,

    Sure – try the following using the sample from this post:

    • Right-click on the Repeating Table used to add new items and select Conditional Formatting
    • Click Add

    • From the first box choose the field: Name

    • From the second box choose: is equal to

    • From the last box choose Type Test and enter: Title

    • Select Hide this control

    • Test!

    What this will do is prevent the Title field from showing in this repeating table. Now, you can submit items without a title but, by default, the title field shows in the list and a new item without a title shows: "No Title."

    Scott

  • shakes11 says:

    Thanks Scott, it works!! My next question (and i think i might have the answer to this already, but I just wanted a confirmation) is if I want to point to a list that already exists, and the Title field has been renamed, is it possible to still link to it?

    I am assuming the answer is no, because I tried, with no success (I am guessing that one of the columns is the title field, I did not try all of them).

    Thanks again!

  • infopath says:

    Hi shakes11,

    Chances are it was just the "caption" that was changed – the underlying name of the field is probably still "Title."

    Scott

  • infopath says:

    Hi Leary,

    I too spent some time trying to get this to work in a similar fashion as the "add" but kept running into issues…and then ran out of time to continue working on it.

    The way I do this now is to use custom code – there is a sample earlier in this post.

    Scott

  • paras2020 says:

    Hi Team,

    I have followed every step in this article. I receive this error:

    " An error occured while the form was being submitted."

    Thank you.

  • paras2020 says:

    OK, Please ignore the above post. I am getting a new error.

    Records were submitted. But I am not seeing it in the list.

    Thank you.

  • paras2020 says:

    OK, Please ignore the above post. I am getting a new error.

    Records were submitted. But I am not seeing it in the list.

    I checked the GUID. Nothing was modified.

    Thank you.

  • paras2020 says:

    I made even more progress…

    When I add a new task in the list via Sharepoint it loads in the Infopath form.

    When I try to add records to Sharepoint via Infopath. It does not work. Do you have any idea as to why this is not working.

    Thanks.

  • infopath says:

    Hi paras2020,

    A couple of things to check:

    • Make sure you are using the correct "lists.asmx" web service for your site
    • Make sure the fields you reference in the "Add List Item Template.xml" file contain valid fields that actually exist in the list.

    Scott

  • paras2020 says:

    BTW….is there a math function in Infopath which an create a random as the form loads. Sorry for going off topic.

    Thanks in advance.

    Paras

  • paras2020 says:

    Here is my XML and content of the custom list. I do not see anything wrong with it. Do I need to include an ID field? Thank you for taking the time to help me out.

    Column (click to edit) Type Required  

    Title   Single line of text  

    useremail   Single line of text  

    category   Single line of text  

    usercontactname   Single line of text  

    Userdepartmentservice   Single line of text  

    Userbranchbusiness   Single line of text  

    Usercategory   Single line of text  

    Userdescription   Single line of text  

    Userpcrnumber   Single line of text  

    Userdaterequired   Single line of text  

    Userifmandatory   Single line of text  

    Userequipment   Single line of text  

    Userlocationofservice   Single line of text  

    Userrequestno   Single line of text  

    Userrequestdate   Single line of text  

    Status  Choice  

    Created By  Person or Group  

    Modified By  Person or Group  

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

    &lt;Field Name='Title'&gt;&lt;/Field&gt;
    

           <Field Name="useremail"></Field>

           <Field Name="category"></Field>

           <Field Name="usercontactname"></Field>

           <Field Name="Userdepartmentservice"></Field>

    &lt;Field Name=&quot;Userbranchbusiness&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Usercategory&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userdescription&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userpcrnumber&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userdaterequired&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userifmandatory&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userequipment&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userlocationofservice&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userrequestno&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Userrequestdate&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Status&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Created By&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Modified By&quot;&gt;&lt;/Field&gt;
    

       </Method>

    </Batch>

  • paras2020 says:

    In the rules for the Submit button this is what I have:

    Submit using a data connection: Web Service Submit

    Query using a data connection: Add List Item Template

  • paras2020 says:

    In the future I am going to be pulling in data from active directory to pre populate this fields. How would I do with a repeating table?? PLease advise.

  • paras2020 says:

    I am using the method UpdateListItems in the web service. Thanks.

  • paras2020 says:

    Hi Scott,

    I also have the list I pointing to is workflow enabled….could that be causing the problem? Thanks

  • paras2020 says:

    Is there away to adopt cascading menus to this infopath form??

    Thanks.

  • mayankagarwal says:

    Hi Guys

    thanks for the great post, really helped a lot

    If you can shed some light on how robust this method it.

    For example if I add a new column to the list, and recreate my xml file, the sumbit function stops to work, it will give you that " form successfully submitted" but there are no entries in the list.

    Also I have faced that this method works on one list and not the other, both the lists are done up exactly the day way.

    Can you please suggest any ways to make the infopath form control datatype compatible with lists.

  • GLazkano says:

    Hi Scott, I’m trying to update a sharepoint list field and I followed all the steps, but it doesn’t write the sharepoint list.

    There’s no error or messages: it’s simply not writting the data.

    Is there a reason for that?

    Thanks!

  • brandtsmith says:

    One observation I had was that I needed to construct a custom list…and make the field names exactly as the AddListItemTemplate.xml…I was unable to submit to a OOTB MOSS Contact list…any suggestions?

    ??? tho – what if I want to submit a batch of say 350 items to the list? How do you construct the AddListItemTemplate.xml so that you can add additional items? (I’ll actually populate my ‘submit list’ from a sql table-selectively)

  • sowmyasimha says:

    Hi Scott,

    Do all the fields in the table have to be Single Line Text. I would like to have some that are Rich Text (Multiple line) type columns from the sharepoint list included here. Is there some way I can do it?

    Thanks!

    Sowmya

  • infopath says:

    Hello everyone,

    I have been extremely busy lately with support issues so I will try to address your questions as soon as possible.

    Scott

  • brandtsmith says:

    Here is a support file that works with OOTB Contact list…with an additional field added as well…using 2 fields in the support file to get the field names to appear as I need…base field names for the submit don’t change…just only display the ‘DiaplyName’ on th IP form…still want to submit multiples????

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

     &nbsp;&lt;Field Name=&quot;Account&quot; DisplayName = &quot;Account&quot;/&gt;
    

             <Field Name="Title" DisplayName = "Last Name"/>

             <Field Name="FirstName" DisplayName = "First Name"/>

             <Field Name="FullName" DisplayName = "Full Name"/>

             <Field Name="Email" DisplayName = "E-mail Address"/>

             <Field Name="Company" DisplayName = "Company"/>

             <Field Name="WorkPhone" DisplayName = "Business Phone"/>

             <Field Name="HomePhone" DisplayName = "Home Phone"/>

             <Field Name="WorkFax" DisplayName = "Fax Number"/>

             <Field Name="WorkAddress" DisplayName = "Address"/>

             <Field Name="WorkCity" DisplayName = "City"/>

             <Field Name="WorkState" DisplayName = "State/Province"/>

             <Field Name="WorkZip" DisplayName = "ZIP/Postal Code"/>

             <Field Name="Comments" DisplayName = "Notes"/>

       </Method>

    </Batch>

  • infopath says:

    Hi everyone,

    Let’s see if I can address some of these questions:

    • paras2020: After adding the connection to your list, extract the files from your XSN (File -> Save as source files), open Manifest.xsf in Notepad and look at the SharePoint field names in this file…do they match exactly what you have in the embedded XML file?
    •  mayankagarwal: Do the same steps noted above for paras2020 to make sure the names match. Also – review the comments from this blog…there are a number of other things you should confirm that have been discussed here previously.

    •  GLazkano: Have you reviewed all the comments in this blog? There are a number of things to confirm: using the correct lists.asmx web service, insuring the field names in your XML file are spelled identical to the columns in your list, making sure there are no fields in your XML file that do not exist in your list, etc.

    •  sowmyasimha: So far, I have not been able to get rich text type fields to work. I have not spent much time trying to find a workaround…if there is one. Unfortunately I have just not had time.

    • For everyone that wants to submit multiple items: there may be a way to do this without code but I have not had any time to look into this. Currently the only way I have tested is with custom code: have a repeating node (i.e. a repeating table) on your View and use custom code to loop the items and add them to the list bu specifying the CAML query in your code.

    Scott

  • GLazkano says:

    Thanks for your reply.

    I reviewed all the fields, all the things that could be wrong, and  everything is ok. If I change or modify the fields to another one it fails, but in my case it doesn’t fail, it only doesn’t do anything.

    I reviewed the list.asmx and I’m using the correct list.

    I’m really confused.

  • infopath says:

    Hi GLazkano,

    Do the column names in your SharePoint list contain any spaces? If so, then chances are the actual name is something like this in the connection: Test_x0020_Field.

    However, if this is not the case then I would encourage you to open a support incident so someone can look into this further for you.

    Scott

  • GLazkano says:

    Hi,

    The name of the sharepoint field I was trying to modify contains a space, but I changed it today and the field is now "Stock_virtual".

    I’ve been working on it the entire morning, but it doesn’t work.

    How can I open a support incident?

    Thanks

  • infopath says:

    Hi GLazkano,

    You can either call 800-936-5800 or start a support request here: http://support.microsoft.com/gp/assistsupport

    I know I keep harping on this <G> but make sure you have checked the following:

    • Your XML file does not contain any additional fields than what you have added as columns
    • Those fields are spelled exactly as they are from SharePoint (to verify this, use the Save as Source Files option from the File menu and look at the field names in the manifest.xsf file)

    • You are using the lists.asmx web service for the appropriate site you are using

    • You have specified the correct list GUID

    • Make sure this article does not apply: http://support.microsoft.com/kb/840549

    • Have you renamed the "Title" field in your list? If so, this will still need to be referenced as "Title" in your XML file.

    • Are there any errors in the Application Event log after submitting the data?

    Scott

  • coleruiz says:

    I tried this and it works well.

    However, I found out the hard way that I can only have 5 fields on the list.   Also, you cannot have special characters or spaces on the field name.  

  • coleruiz says:

    Ignore my comment about having maximum of 5 fields. InfoPath arbitrarily  rename my 5th field.  Checking the  manifest.xsf do not the correct names between sharepoint list and name specified on the XML.  

    InfoPath truncates the field name if it’s longer than 33 characters.

    Very strange!

  • infopath says:

    Hi coleruiz,

    Glad to hear you were able to resolve the issue!

    Scott

  • paul_g_ch says:

    In the current senario I want to add some additional functioality :

    I want to submit file attachment to the list library using this InfoPath form.

    Please reply asap who is aware about how to do this.

    Thanking all of our member

    Gopal

  • Jdaskalis says:

    Great Post.  I would love to create a repeating table that would allow managers throughout the country to submit timesheet entries for their staff.  Is it possible to do what you be in a repeating table format?  If so please point me in the right direction.  

    Thanks

  • infopath says:

    Hi Jdaskalis,

    I have not been successful in implementing this functionality without writing code – if this is of interest to you, let me know and I will post the sample code.

    Scott

  • Gmann001 says:

    Hello! And thank you for the post, it’s exactly what I’ve been looking for (and very detailed)!

    I’ve followed the instructions exactly as listed and I am getting a SOAP error.  My form retrives data (that I’ve entered via Sharepoint) just fine, but it will not submit data via the form to my SharePoint list.

    The error is…

    "List does not exist"

    "The page you selected contains a list that does not exist.  It may have been deleted by another user.  Click "Home" at the top of the page to return to your Web site."

    I’ve checked, double-checked, and rechecked again the GUID, etc.

    I even went as far as create a new SharePoint site just for this test and restarted your steps.  And once again I get the error. I also had the admin restart the server last night…. still no luck.

    If it matters, I am using InfoPath 2007 and connecting to SharePoint 2003.

  • Gmann001 says:

    Ok, here’s another question…

    Is there a way to do this without an XML (CAML) file?  That way the form is all "self-contained" in a single file?

  • Gmann001 says:

    It figures I found my own solution right after I submit the question about the SOAP error.  It appears I had the wrong Web Service listed.  Since my site is a sub-site, I needed to use that service and not the one for the main (root) site.

    I was using…

       /myServer/_vti_bin/lists.asmx

    and should have been using…

       /myServer/sites/mySiteName/_vti_bin/lists.asmx

    Thanks again for the great example!

  • infopath says:

    Hi Gmann001,

    I am glad you were able to get this working! Yes – you can do this without the XML CAML file – this was needed just to be able to add to a list without code. If you don’t mind using code, you don’t need this file. Look through the past comments here and you will see some sample code I provided for updating list items – this can also be used for adding items as well.

    If you prefer to stay with the no code solution then that XML file is needed but keep in mind, it is indeed part of the solution – everything is in the one XSN file.

    Scott

  • ArthurM says:

    Scott,

    I have followed the process you have created.  I hit the send button infopath states everything is working correctly. But everything is NOT working correctly.  The only Where on a server would be a error log for Sharepoint

  • infopath says:

    Hi ArthurM,

    Please make sure you review all comments in this post. A number of folks have run into the issue of getting a "successful" message and then nothing appearing in the list. There are a number of reasons why this may occur and that information is throughout this post.

    Scott

  • Gmann001 says:

    Hello again!  When looking at the post from October 19 (your sample code), I am unsure how "Create a new instance of our "Lists" web service"

    Your code states..

    server_Lists.Lists myList = new SubmitToSharePointList.server_Lists.Lists();

    Since I am a starting VB programmer (due to company restrictions), my converted code looks like..

    Dim myList As server_Lists.Lists = New SubmitToSharePointList.server_Lists.Lists()

    It shows that there is no such thing as "server_Lists".  Am I missing something here?  Should I not be taking your code verbatim?  Is there something that I need to import/using (i.e. Imports System)?

    I have a feeling this is a dumb question, but I am new to this and I’m having a heck of a time figuring it out.

    Thanks again

  • Gmann001 says:

    Is there a way that I can create a form that doesn’t display the fields via a repeater table?  I need to create a form that has the look/feel as dictated by our legal department and unfortunately that look/feel is not a vertical table.  I need some fields horizontal to each other and I am required to place some text between other fields.

    Basically I have a custom form that I would like to apply this method to.  Any help would be great…thanks!

  • infopath says:

    Hi Gmann001 – in regard to the "lists" web service you will need to add a web reference to your code that points to the web service.

    For the layout question – yes, what you can do is add a repeating table to your form with the appropriate fields. Then you will use code to either populate the fields in the Add List Item Template.xml file or simply build the CAML query in your code.

    If you review some of my past comments, there is sample code for updating a list item – this is the same basic premise you would use for adding one as well.

    Scott

  • pmdci says:

    Hi there. I have a question which I hope someone can help me with.

    What I would really like to do is to display two tables.

    Both tables would display the items included in the SharePoint list (e.g.: the MyContacts list in the example above).

    However, table 1 would show only items where the Boolean column MyColumn equals 0.

    Table 2 would show only items where the Boolean column MyColumn equals 1. Plus, for each row there would be a checkbox.

    Upon submitting the form, for every item ticked in table two would update the MyColumn column in SharePoint. Thus updating the list of TABLE 1.

    Is this possible to be done, without coding? I am a little bit rusty with InfoPath these days but I think this could be possible with the use of filters and conditionals?

    Thank you a lot in advance!

    Regards,

    P.

  • infopath says:

    Hi pmdci,

    What you are trying to accomplish would require custom code. As you have probably read in the comments on this post, InfoPath is not able to submit to a SharePoint list out of the box. You can "add" items without code but to edit/delete an existing item it requires custom code.

    Scott

  • ConvergePoint says:

    A good post for anyone starting to use InfoPath.

  • saefeldin says:

    Nice Post.

    i works perfectly.

    but how can i use other field types(drop-down menu, people and groups, etc…) in this info path form ??

    i used this post in Task list and it works just fine, but "Assigned to" field in the form i write numbers not names to get a result !!!

    i think this is the id of the users or groups.

    how can i get users from my domain in assigned to field ??

    appreciate any help.

  • infopath says:

    Hi saefeldin,

    You are correct – you will need to pass in the SharePoint ID of the user so that it will resolve to the domainuser value. The only way I know of to do this is to either write the code behind InfoPath or create a small custom web service that takes the domain name and returns the SharePoint User ID. Here is a sample web service that I have used to get this information; however, it is important to note that in doing this I have only been successful in using code behind InfoPath to add tasks – in other words, this is not a codeless solution:

    [WebMethod]

       public int GetUserID(string strSite, string strDomainUser)

       {

           if (strDomainUser != "")

           {

               SPSite site = new SPSite(strSite);

               SPWeb web = site.OpenWeb();

               SPUser user = web.AllUsers[strDomainUser];

               return user.ID;

           }

           return 0;

       }

    If you review prior comments you will see sample code I have provided to "update" existing contacts. This is the same basic code that would be used to "add" a new task programmatically – you would just need to incorporate something like the above so you can set the "AssignedTo" field to a valid SharePoint ID.

    Scott

  • m181354 says:

    The example above worked great but now I want to create a CAML for my list and I can not get it to work unless I use the CAML created in the example above.  My CAML looks like the following.  Do yoiu know why.  I have started from scratch with a new form and a new custom list.

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="TaskNo"></Field>

           <Field Name="TaskDescription"></Field>

           <Field Name="ProcurementTravel"></Field>

           <Field Name="LaborEstimate"></Field>

       </Method>

    </Batch>

  • infopath says:

    Hi m181354,

    You will want to verify the following items:

    • Your list GUID is correct
    • Your "Lists.asmx" web service data connection is referenced at the correct level (i.e. http://server versus http://server/site)

    • Your XML file does not contain any additional fields than what you have added as columns

    • Those fields are spelled exactly as they are from SharePoint (to verify this, use the Save as Source Files option from the File menu and look at the field names in the manifest.xsf file)

    • Make sure this article does not apply: http://support.microsoft.com/kb/840549

    • Have you renamed the "Title" field in your list? If so, this will still need to be referenced as "Title" in your XML file.

    Scott

  • m181354 says:

    My manifest.xsf file has the wrong Sharepoint names in them but the correct Infopath names. I have the right GUID and the correct "Lists.asmx" web service data connection.  I do not know why the Sharepoint names still match the names fom the example above.   See below

        &lt;xsf:dataObject name=&quot;JDAM Task List&quot; schema=&quot;JDAM Task List.xsd&quot; initOnLoad=&quot;yes&quot;&gt;
    
            &lt;xsf:query&gt;
    
                &lt;xsf:sharepointListAdapter siteUrl=&quot;<a rel="nofollow" target="_new" href="https://tcc.web.boeing.com/jdam/JDAM/&quot;">https://tcc.web.boeing.com/jdam/JDAM/&quot;</a> sharepointGuid=&quot;{0F7220FC-E894-4523-9043-6F6B367A339F}&quot; infopathGroup=&quot;JDAM_Task_List&quot; queryAllowed=&quot;yes&quot; submitAllowed=&quot;no&quot; name=&quot;JDAM Task List&quot;&gt;
    
                    &lt;xsf:field sharepointName=&quot;Title&quot; infopathName=&quot;Title&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field sharepointName=&quot;FirstName&quot; infopathName=&quot;Task_No&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field sharepointName=&quot;LastName&quot; infopathName=&quot;Task_Description&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field sharepointName=&quot;Email&quot; infopathName=&quot;Procurement_Travel&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field sharepointName=&quot;Phone&quot; infopathName=&quot;Labor_Estimate&quot;&gt;&lt;/xsf:field&gt;
    
                &lt;/xsf:sharepointListAdapter&gt;
    
            &lt;/xsf:query&gt;
    
        &lt;/xsf:dataObject&gt;
    
  • infopath says:

    Hi m181354,

    What you may want to try is deleting the connection from Tools -> Data Connections and then re-adding that connection back. I don’t know that I have ever seen that behavior before where the XSN did not pick up the correct fields – that is odd.

    Scott

  • cmf6868 says:

    Hi Scott,

    I am trying to follow the steps you have included in your article and am having a problem with #4 in Step 6: Add the "lists.asmx" web service. When I double-click the "updates" parameter, I see the same thing listed as for the "listname" parameter and not the "Add list Item Parameter" data source as is specified in #4. Do you have any idea as to what I have done wrong?

    Thank you.

  • infopath says:

    Hi cmf6868,

    When you double-click the "updates" parameter, by default, you will see what nodes are in the "Main" data source. There is a "Data Source" drop down box at the top – click this and select "Add List Item Template."

    Scott

  • cmf6868 says:

    I got it Scott! Thank you so much for your help and your excellent article!!!

  • infopath says:

    Excellent! 🙂

    Scott

  • alpha_geek says:

    Hi Scott,

    Thanks for the info on this, but I am still struggling. I am a victim of the successful submit but no data issue.

    I can get the example to work no problem, so I have moved on to my own form (a purchase order form).

    This form contains a series of fields, and a repeating table. The information outside of the repeating table is to be submitted to "list1" and the data inside the repeating table is submitted to "list2".  The code for submitting the 2 lists is identical (bar variable names), and list1 is submitted before list2.

    List2 works without error, but no matter what I do I can’t get list1 to work. I have verified the GUID, the webservice path, the defined fields in the XML and the spelling and case. The MS KB does not apply to me. I have compared my list1 and list2 and found no difference in the way they are set up.

    None of the field names have spaces, but when I check the manifest.xsf I can find the references to the fields but all of them have spaces in them. This is true for both list1 and list2 !?! Can you provide a little more info regarding the manifest.xsf and how to correct problems if they are found? I take it I can’t just edit the file and save it back?

    I have been at this for 3 days, and I am at a loss. If it was not for the fact that one list works but the other does not, I would have thought it was me.

    Thanks again

  • infopath says:

    Hi alpha_geek,

    Are you using code or just the default "add" like the sample? Also – can you describe your data source and lists and let me try to repro?

    Scott

  • callumbundy says:

    Hi Scott,

    Brilliant article, worked perfectly for me. The next thing I want to do however is combine this infopath submit function with the data gathered from the users MOSS profile (This Article: http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-2D00-Get-the-current-user-without-writing-code.aspx )

    Basically what I need to be able to do is to collect users infomation from MOSS (no problem) and then submit that same infomation back into a sharepoint list, with some additional user input fields.

    Any idea how I might be able to achieve this?

  • infopath says:

    Hi callumbundy,

    You will need to get the data from the User Profile into fields in your main DOM. If you only return information for one user then you could use either Rules or the Default Value property to pull the data from the User Profile result into your main DOM. Then I would expect it to be basically like the sample…unless I am missing something?

    Scott

  • infopath says:

    Hi callumbundy,

    You will need to get the data from the User Profile into fields in your main DOM. If you only return information for one user then you could use either Rules or the Default Value property to pull the data from the User Profile result into your main DOM. Then I would expect it to be basically like the sample…unless I am missing something?

    Scott

  • arosoccer says:

    Scott,

    Thanks for your help so far. I am looking to attach the .xml file that would be generated on a "Submit to Sharepoint Document Library" to the list item that form generates. How would I go about doing that? I can use the

    XPathNavigator myNavigator = this.MainDataSource.CreateNavigator();

    string wholeXML = myNavigator.OuterXml.ToString();

    to get the XML representation of the form. I’m just not sure how to make it an attachment on the Sharepoint list.

    Thanks in advance,

    Andrew

  • infopath says:

    Hi Andrew,

    Unfortunately I don’t know how to programmatically create a SharePoint list attachment. You may want to ping one of the SharePoint blogs as this is not InfoPath specific. For instance, you could really just write some code behind a Windows form that grabs an XML file and now you need to att this as a List attachment.

    I am sorry I don’t have a better option for you.

    Scott

  • hollyanne says:

    Hi Scott,

    Thank you for this great demo.  I have used it in a purchase request form to populate a vendor drop-down.    It works great.  Now I would like to use the same idea to update an Expense number field.  

    I want to take a field that is automatically populated upon opening the form and send it to a different sharepoint list.  Rather than opening a form that I need to fill in, can I send an already populated field to a sharepoint list?  It seems like it should be easy to do, but I havent figured it out yet.

    Thanks

    Holly

  • infopath says:

    Hi Holly,

    Before I address the question, I need to be sure I understand what you need: so you open an InfoPath form and upon opening, some field is automatically populated. When you then submit that form to a list, you also want to submit just that auto-populated field to another list as well?

    Am I understanding correctly?

    Thanks,

    Scott

  • hollyanne says:

    Hi Scott,

    Yes, except that I want the field to be sent to the list immediately after the field is populated.  

    I have my purchase request form and a secondary sharepoint list called PR# with a field called eNumber.  Right now I am using the following to populate a field upon opening the form;

    max(eNumber) + 1  

    I would like the next rule to immediately submit the number back to the PR# list so that it is available the next time the form is open.  Basically an autonumber.

    Thanks

    Holly

  • infopath says:

    Hi Holly,

    OK – Based on my understanding, I have this working, I believe, as you need. Here are the changes I made to my sample XSN:

    • Created a new "Add List Item Template" XML file like this:

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="eNumber"></Field>

       </Method>

    </Batch>

    • Saved this as: Add List Item Template_PRNumber.xml"
    • Created a new "Receive" data connection to this XML file, chose to include this as a Resource file and set this to retrieve the data when the form opens

    • Added another "Receive" data connection to my PRNumber list and included the "Title" and "eNumber" fields

    • Added a new field to my main data source called: ListName_PRNumber and set the default value of this to the list GUID of my PRNumber list (same steps as when you set the "ListName" field from this sample)

    • Added a new "Submit" data connection just like the one in the sample except I am using the "ListName_PRNumber" field for the ListName and the "updates" parameter points to the "Batch" node from my new Add List Item Template_PRNumber file

    Now, for the field in my main data source that is to store and display the incremented number, I am not using the "default value" for this field – I am using a Rule on the form open so that this will only fire if that field is blank. So if the field is blank, I have the following actions:

    • Set a field’s value

          – Field: field in my main data source to store the new value

          – Value: max(@eNumber) + 1

  • Set a field’s value

        – Field: this is the "Field" node from the Add List Item Template_PRNumber connection (not the "name" field – just select the "Field" repeating node)

        – Value: I selected the field from the above step that stores the new value

  • NOTE: When setting the above "Field" it is going to set both the eNumber and Title fields to the newly incremented value. There is no getting around this unless you use code. For my sample, this is fine…it just means the title is the same value as eNumber.

    • Submit using a data connection

          – The data connection is the new submit connection back to the PRNumber list

    So in my testing, when I double click the XSN, the field in my main data source is blank so the Rule kicks off and sets that value to the max value from the PRNumber list + 1. That rule then sets the "Field" node in the new Add List Item Template_PRNumber connection to this newly incremented value and submits it back to the PRNumber list.

    I do have some concerns about this method: if you have a lot of new forms being created, then this list is going to get big relatively quickly. I am not a SharePoint expert so you may want to see if there will be a performance issue if the PRNumber list grows to, say, 1000-2000 items.

    I hope this helps!

    Scott

  • hollyanne says:

    Hi Scott,

    It worked like a charm.  I will be setting up a workflow to clean up the enumber list after it reaches 100 since I only need it for the autonumber feature.

    Thank you very much

    Holly

  • infopath says:

    Hi Holly,

    That’s great to hear!

    Scott

  • levar says:

    Hello Scott,

    Thank for your article it’s really great.

    I tried you method on the simple list and it works, but when I try to use it on the task list it doesn’t work. Publishing is successful, but the item doesn’t appear. Is there any difference between list and task, as I know task is list to.

    Thanks in advance!

  • infopath says:

    Hi levar,

    I have been able to get this to work but there are a few caveats:

    1) The "AssignedTo" column must be the SharePoint ID for the user

    2) The "Status" column needs to be entered as the textual value (i.e. Not Started)

    3) The "Priority" column needs to be entered as the textual value (i.e. (2) Normal)

    4) Any date fields need to be entered in the format of: yyyy-mm-dd (for en-US anyway <G>) So as an example: 2008-09-17

    Here is what I have tested in my Add List Item Template XML file:

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="AssignedTo"></Field>

           <Field Name="Status"></Field>

           <Field Name="Priority"></Field>

           <Field Name="DueDate"></Field>

           <Field Name="StartDate"></Field>

           <Field Name="PercentComplete"></Field>

       </Method>

    </Batch>

    And here are sample values I have entered for each – in the same order as above:

    Test1

    1

    Not Started

    (2) Normal

    2008-09-17

    2008-09-16

    .50

    NOTE: The "1" above for AssignedTo again is my SharePoint ID. This is where it could get a bit tricky. The way I have done this (and there may be better ways that I don’t know of) is I have a custom web service on my WFE that accepts the domain name of the current user and returns the user ID:

    [WebMethod]

       public int GetUserID(string strSite, string strDomainUser)

       {

           if (strDomainUser != "")

           {

               SPSite site = new SPSite(strSite);

               SPWeb web = site.OpenWeb();

               SPUser user = web.AllUsers[strDomainUser];

               return user.ID;

           }

           return 0;

       }

    However, even once you have this there is not a simple way to set this up for this sample as the ultimate way to do this would be, say, have a dropdown box for the "AssignedTo" field and when you select the user it actually stores the SharePoint ID.

    This is one of the cases where the better option may be to use code instead of the steps in this initial sample.

    I hope this helps!

    Scott

  • levar says:

    Hi Scott,

    Thanks a lot it was great help!!!

  • infopath says:

    Hi levar,

    Glad to help!

    Scott

  • Nathu says:

    Hi

    does this work with Windows sharepoint services 3.0 Also ?

    Narsinh

  • infopath says:

    Hi Narsinh,

    I’ve never tried on a WSS only server but I don’t believe there is any reason why this would not work…assuming the "lists.asmx" web service is a part of WSS.

    Scott

  • Nathu says:

    Scott

    I had followed every thing mention you above article .

    but not new item doesn`t add to list . where if I add manually new Item it does Query and able to see that

    any help

    Narsinh

  • infopath says:

    Hi Narsinh,

    I know there are a lot of comments on this post but have you gone through all of these? There are a number of reasons why the entry may fail to appear and most of these have been covered in these comments.

    Scott

  • Nathu says:

    Hi Scott

    IS any where logs get generated to check out  what getting wrong .

    Actually I wants create few forms new joinees which get mail to resptive group as well as store inform store in list

    so that same can be used various places .

    I had tried with your example but it just message it got submitted but does show item in the list

    Pls help

    Narsinh

  • Nathu says:

    Hi Scott

    Great news it work your sample list  for me on old test site. it seems there some problem with title flied.

    Thanks for you artlicle .

    will trouble if need any help for actuall site implementation

    Thanks

    Narsinh

  • infopath says:

    Hi Narsinh,

    I don’t believe this is logged anywhere in SharePoint. Did you actually look through the various posts on this site? There are various reasons why you are seeing this behavior and I personally have seen and covered those here in this post.

    Scott

  • JeffTemple says:

    Hi Scott,

    Thanks for the helpful article and following up on the postings.  I have completed the fields but have the following issue.

    My submit fires correctly and creates a row in the sharepoint list.  It however is completely blank.  None of the data is carried from the form into the SP list.

    Any Ideas??

    An InfoPath Newbie

    Jeff

  • suz_george@hotmail.com says:

    great post, it worked the first time.  Is it possible to show the field description in the infopath form?  How would I define this in the xml?

    thank you!

    suz

  • infopath says:

    Hi Jeff,

    A few things to check:

    • Make sure your XML file contains only those column names you added – if there is a column in the XML file that does not exist it will cause a problem.
    • Make sure the names you specified are spelled correctly (including capitalization)

    • With the columns that you added in SharePoint – did you include spaces in the name? If so – it’s not as simple as just adding spaces in the name in your XML file (to see how the names come into InfoPath, create a new XSN with a receive connection to your list. Then from the File menu choose Save As Source Files and look in the manifest.xsf file.)

    Suz – glad this has worked for you! In regard to how to get the "Description" field – oddly enough the actual SharePoint name of this field is: "Body" – with a captial "B." This is what you will need to add to your XML file. 🙂

    Scott

  • emumu says:

    Sorry to repost since I have not seen the first message I posted yesterday…

    I got an error message saying the GUID should be 32 digits with 4 dashes. And, I double checked the GUID in the URL of the SharePoint list and it was way more than 32 digits and has 5 dashes.

    Any thoughts? Thanks. -ET

  • infopath says:

    Hi ET,

    It sounds like you may be using the "encoded" version of your list GUID. Here is what you need to do:

    • Navigate to your list
    • From the Settings button choose List Settings

    • You should see something like this in your address bar:

    List=%7B1E76517B%2D2C36%2D4473%2DA420%2DA737D98589BC%7D

    • What you want is the portion after "List="

    %7B1E76517B%2D2C36%2D4473%2DA420%2DA737D98589BC%7D

    • Now, you need to "decode" this GUID as follows:

    %7B = {

    %7D = }

    %2D = –

    • So if you replace the encoded characters as described, you end up with this, which has 32 characters and 4 hyphens.

    {1E76517B-2C36-4473-A420-A737D98589BC}

    Scott

  • dishaniti says:

    Hello

    In my form library, I am have enabled – email enabling list, where user email infopath form and it automatically adding in to form library. It is working very nicely. Now I want to extent this feature for some users where user will mail an XML  file in different format which is not same as form library have. I want to transform their XML into infopath XML format. I  just need a way to accept the XML and then use the XSLT to create a the form in predefined form template on MOSS and upload it to the SharePoint site.

    Is this possible?

    Disha

  • infopath says:

    Hi dishaniti,

    Just a thought: either create code on a SharePoint event handler to do this or create a custom web service that takes the XML, performs your modifications to the file and then pushes the "fixed" file back to the library.

    If you need direction on using a SharePoint event handler I would encourage you to post that request to a SharePoint forum or blog as I don’t want to steer you in the wrong direction. 🙂

    Scott

  • auropravin says:

    Hi Scot,

    I need to add a drop down list, a calendar and rich text box along with the normal fields to update my custom list.

    What is the solution for it.?

    Requirement is quite urgent

    please respond

  • infopath says:

    Hi auropravin,

    The only way you will be able to do this is to use custom code. If you did not need the rich text capabilities we could still do this without code; however, with this requirement the only way to accomplish this is via code.

    The steps are basically the same as in this sample; however, here are the modifications you need to implement:

    1) My list is called: TestList and consists of the following field names and data types:

    txtName, Single line of text

    txtDropDown, Single line of text

    txtDate, Date and Time

    txtRichText, Multiple lines of text (rich text selected)

    2) My Add List Item Template.xml file is as follows:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="txtName"></Field>

           <Field Name="txtDropDown"></Field>

           <Field Name="txtDate"></Field>

           <Field Name="txtRichText"></Field>

       </Method>

    </Batch>

    3) Instead of adding the "Add List Item Template" fields to your View, you will need to create your own data structure in the main DOM. This is what I am using as a sample:

    myFields

        ListName

        gpTestList (Group)

             _Title (string)

             _Name (string)

             _Dropdown (string)

             _Date (string!)

             _RichText (XHTML)

    4) Drag "gpTestList" to your view as a Section with Controls

    5) Change the "_Dropdown" text box to a Dropdown control

    6) Change the "_Date" text box to a DatePicker control and set the Format to just display the date

    7) Add a button control (for the submit process) and you will use code like this on the click event (note you need to use the "InnerXml" property when setting the rich text value!):

    XmlNamespaceManager ns = this.NamespaceManager;

    //Create a DataSource object for the Add List Item Template data source

    DataSource dsAddListItem = this.DataSources["Add List Item Template"];

    //Create an XPathNavigator object for that data source

    XPathNavigator xnAddListItem = dsAddListItem.CreateNavigator();

    //Create an XPathNavigator object for the main DOM

    XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

    //Create XPathNavigator objects for each of our fields in the main DOM

    XPathNavigator xnTitle = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Title", ns);

    XPathNavigator xnName = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Name", ns);

    XPathNavigator xnDropdown = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Dropdown", ns);

    XPathNavigator xnDate = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_Date", ns);

    XPathNavigator xnRichText = xnDoc.SelectSingleNode("/my:myFields/my:gpTestList/my:_RichText", ns);

    //Set the values of each field in the Add List Item Template data source to the

    //values from the main DOM

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[1]", ns).SetValue(xnTitle.Value);

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[2]", ns).SetValue(xnName.Value);

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[3]", ns).SetValue(xnDropdown.Value);

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[4]", ns).SetValue(xnDate.Value);

    xnAddListItem.SelectSingleNode("/Batch/Method/Field[5]", ns).SetValue(xnRichText.InnerXml);

    //Submit the data

    this.DataConnections["Web Service Submit"].Execute();

    When I test this, the data submits correctly including rich text data (i.e. I bolded some text, changed the font color of other text, etc.)

    I hope this helps!

    Scott

  • jamiehook01 says:

    Hello,

    I have created this form and it works fine within infopath but when it is published to a document library it will open and retrieve data but throws an error when it is submitted.

    This is just a generic error.

    Can any one help????????

  • jamiehook01 says:

    Just an update to my above comment i have also tried this suggestion but it gave the same error.


    Tuesday, September 11, 2007 4:01 PM by infopath

    Hi Brian,

    I just tested this process after pubishing my XSN as a Site Content Type and it worked from the browser without issue.

    If you would, try these steps:

    • Delete the Content Type from the document library where you added the published content type
    • Delete it from the Site Content Type list

    • Delete the XSN from the saved location

    • Create a new library on the same site called: ContentTypes

    • Publish the XSN as a Site Content Type and save it in the ContentTypes library

    • Add it as a Content Type to your document library

    • Test

    Scott


  • infopath says:

    Hi jamiehook01,

    What you will need to do to debug this is enable Verbose logging on your server for the Forms Services categories, reproduce the error and then check the ULS logs on the server – these should provide you direction on why it fails.

    Scott

  • Fishman4 says:

    Hello Scott.

    IRT this post "Monday, October 08, 2007 9:42 AM".

    I have followed the tutorial on how to add to a sharepoint list and it works beautifully.  Naturally, that was not enough and I needed to update and delete.  After further reading, I found your later entry addressing this and I have hit some snags.  I copied your code into my form, but I am getting some build errors.  It is probably just some syntax, but I am not a programmer and I am struggling.  I get these two errors:

    The name ‘e’ does not exist in this context.

    The type or namespace name ‘serverName’ could not be found (are you missing a using directive or an assembly reference?)

    Here is my code:

    public void InternalStartup()

           {

               ((ButtonEvent)EventManager.ControlEvents["UpdateList"]).Clicked += new ClickedEventHandler(UpdateList_Clicked("Update", e.Source.CreateNavigator()));

           }

           public void UpdateList_Clicked(string strOperation, XPathNavigator e)

           {

          {

              //Create a new instance of our "Lists" web service

              serverName.Lists myList = new serverName.Lists();

              //Pass the logged on users credentials to the web service

              myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

              //Create a DataSource object for our list data source

              DataSource dsContacts = this.DataSources["MyContacts"];

              //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

              XmlNamespaceManager ns = this.NamespaceManager;

              //Create XPathNavigator objects for each field from our list

              XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

              XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

              XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

              XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

              XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

              XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

              //Create a new XmlDocument to use for specifying the Update CAML query

              XmlDocument doc = new XmlDocument();

              //Create the needed update element

              System.Xml.XmlElement updates = doc.CreateElement("Batch");

              //Create the CAML query passing in the value of each of our fields from the form

              if (strOperation == "Delete")

              {

                  updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Delete’>" +

                  "<Field Name=’ID’>" + xnID.Value + "</Field>" + "</Method>");

              }

              else

              {

                  //Create the CAML query passing in the value of each of our fields from the form

                  updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Update’>" +

                  "<Field Name=’ID’>" + xnID.Value + "</Field>" +

                  "<Field Name=’FirstName’>" + xnFirstName.Value + "</Field>" +

                  "<Field Name=’LastName’>" + xnLastName.Value + "</Field>" +

                  "<Field Name=’Title’>" + xnTitle.Value + "</Field>" +

                  "<Field Name=’Phone’>" + xnPhone.Value + "</Field>" +

                  "<Field Name=’Email’>" + xnEmail.Value + "</Field>" + "</Method>");

              }

              //Update the list

              XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

              XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

              //Requery the data source to reflect the updates

              dsContacts.QueryConnection.Execute();

          }

    Sorry for resurrecting something kinda old, but it would greatly improve my quality of life!  Thanks in advance for your assistance.

    Don F.

  • infopath says:

    Hi Don F,

    The "serverName" issue is most likely caused by either not having added a "web reference" to the "Lists.asmx" web service or you added it and you need to change "serverName" to whatever name you entered for ther web reference.

    In regard to the "e" error, it looks like you have one too many opening braces ("{") after "private void".

    Now, also – the way I wrote this code (if you want to follow it exactly) would be as follows:

    • Assuming you have a button with the ID of: UpdateList, then the only line of code you should have in its "clicked" event is this:

    UpdateList("Update", e.Source.CreateNavigator());

    Then you need the "UpdateList" procedure as follows:

    public void UpdateList(string strOperation, XPathNavigator e)

          {

               //Create a new instance of our "Lists" web service

               sheimserver.Lists myList = new sheimserver.Lists();

               //Pass the logged on users credentials to the web service

               myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

               //Create a DataSource object for our list data source

               DataSource dsContacts = this.DataSources["MyContacts"];

               //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

               XmlNamespaceManager ns = this.NamespaceManager;

               //Create XPathNavigator objects for each field from our list

               XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

               XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

               XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

               XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

               XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

               XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

               //Create a new XmlDocument to use for specifying the Update CAML query

               XmlDocument doc = new XmlDocument();

               //Create the needed update element

               System.Xml.XmlElement updates = doc.CreateElement("Batch");

               //Create the CAML query passing in the value of each of our fields from the form

               if (strOperation == "Delete")

               {

                   updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Delete’>" +

                   "<Field Name=’ID’>" + xnID.Value + "</Field>" + "</Method>");

               }

               else

               {

                   //Create the CAML query passing in the value of each of our fields from the form

                   updates.InnerXml = string.Format(@"<Method ID=’1′ Cmd=’Update’>" +

                   "<Field Name=’ID’>" + xnID.Value + "</Field>" +

                   "<Field Name=’FirstName’>" + xnFirstName.Value + "</Field>" +

                   "<Field Name=’LastName’>" + xnLastName.Value + "</Field>" +

                   "<Field Name=’Title’>" + xnTitle.Value + "</Field>" +

                   "<Field Name=’Phone’>" + xnPhone.Value + "</Field>" +

                   "<Field Name=’Email’>" + xnEmail.Value + "</Field>" + "</Method>");

               }

               //Update the list

               XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

               XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

               //Requery the data source to reflect the updates

               dsContacts.QueryConnection.Execute();

           }

    Scott

  • Arghhhh says:

    Hi,

    I’ve read this page and I’m not sure if it can help me to do what i have to do.

    I explaine : I have a SPS2003 form library that I have to migrate to a WSS 3.0 list.

    The forms have attachment inside them.

    The goal is to populate columns of the list with the datas that are in the form and have the form attachement attached to the list……

    Is it possible ?

    Regards.

  • infopath says:

    Hi,

    There are a couple of "hurdles" you are going to need to address for this to work:

    #1: Attachments in an InfoPath form are base64 encoded – to extract them you need to use custom code (unless you want to manually open each form and save out the file.) Here is a Knowledge Base article to get you started:

    892730: How to encode and decode a file attachment programmatically by using Visual C# in InfoPath 2003 Service Pack 1

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;892730

    ** NOTE: The code in this article was specific to InfoPath 2003. If you are using the new 2007 object model with VSTA, you will need to convert this code.

    #2: Once you extract the file now you need to get it to the appropriate item in your list. The SharePoint "Lists" web service has an "AddAttachment" web method that will allow you to attach a file to a list item so this may be of help.

    However, if you run into any issues using the web service a SharePoint group will be a better option for assistance.

    Scott

  • EricL says:

    Hi,

    This is almost exactly what I needed.  I implemented your solution to make sure it was working and it does add new items to my list.  That’s not quite what I need to do.

    I’ve ready all the posts on updating an existing list item, but I think my needs are somewhat simpler and am hoping you can simplify for me?  I use a lot of C# code-behind so that part won’t be a problem.

    I feed-in an SP List of ‘variables’ which allows me to dynamically control behavior within the code.

    My form submissions are done programmatically based on "OnClick" events.

    Just before submitting the form, I’d like to update just one of my variables which is stored in the ‘variables’ SP List.  I’d like to do it completely behind the scenes.  It’s just a counter for certain actions taken by the user.  

    So I’m wondering how much of your original solution can be eliminated if I merely need to update one existing item with each submit?

    I could go ahead with your suggested "update" code, but I see it involves having buttons for each list item.  My list item is always the same thing (and invisible to the user) with just a varying value being sent to it automatically.

    Thanks for any help you can provide!

    –Eric

  • infopath says:

    Hi Eric,

    I would say just to use the basic code I have here in these comments for doing the "update." The only reason I used a button in the repeating table is so that you could determine which list item you were updating. If you are updating the same one all the time then you can just hard-code the list item ID.

    Scott

  • EricL says:

    Hi Scott,

    Thanks for your reply!  I setup a new solution and am trying the basic update process you’ve listed above.

    I think I’m in trouble.  So far all my coding in the InfoPath code-behind has been done with VS2003 (and until recently against SP2003 sites).  Now our sites are SP2007, but we’re still using VS2003 which has been working OK.

    In order to use the XPATHNAVIGATOR, do I need to upgrade to VS2005 (.net 2.0)?  I don’t seem to find a reference to it from within VS2003 but maybe I’m missing something?

    Also, we have a thousand or so documents in the site I’m working with.  Will it require updates to all the existing documents if we move to VS2005?

    Any other concerns with upgrading to use VS2005 at this point?

    Thanks and sorry for my ignorance on this.  I know there’s obvious advantages for upgrading – it’s just we run very lean so tend to wait until necessary.  I noticed we could start passing variables into InfoPath via the URL string if we were on VS2005 too.  That would be helpful.

    –Eric

  • pcorrell says:

    I have a question. I have an Infopath 2007 form for submitting expenses. The completed form is submitted to a SharePoint Library. No problem there. Depending on the type of expense, specific individuals have to approve the expense.

    I want to create a workflow, based on the type of expense, to feed to the specific individuals for their approval. How can I address this in the Infopath form, and how can the submission kick off the workflow?

    PC

  • Arghhhh says:

    @Infopath

    Hi,

    if I put aside the attachment problem….does this work with existing forms ?

    I mean even if I change the template.xsn using this method, will the forms already created be modified ? How to pupolate the list using the form : do I have to open the one by one to submit them to the list ?

    Sorry if my questions seems dumb but it is quit non obvious to me 🙁

    Regards

  • infopath says:

    EricL:

    Yes – the "XPathNavigator" object is new so you will need to either migrate and use Visual Studio Tools for Applications (behind InfoPath) or Visual Studio 2005 or convert the code in this post to the older object model.

    In regard to "thousands of documents? – are you referring to XSN or XML files? If the thousands of documents are completed XML files and are all bound to the same XSN, then once you make the code change in the XSN the existing XML files will be updated automatically (assuming you have not changed the default behavior) once they are opened.

    Pcorrell:

    There is no true "workflow" capabilities in InfoPath. You can attach a workflow to an InfoPath form or you would typically use InfoPath forms in your workflow (i.e. the Init form, Association form, etc.) However, workflows are created in either SharePoint Designer or Visual Studio and support for these are handled through the SharePoint team. So I am not trying to "push you away" but I do very little with workflows here in the InfoPath group and would suggest you post that question to a SharePoint/Workflow group.

    Arghhhh:

    Ok – let’s forget the attachment part of the question for a moment. You have an existing "library" that contains completed InfoPath XML files – correct? And now what you want/need to do is take the "data" that is in each of those files and migrate/move/copy to a new SharePoint "list" – correct?

    So assuming my understanding is correct there is nothing built-in to InfoPath that would facilitate this. First off – you can not "submit" InfoPath forms/data directly to a SharePoint list…hence the reason for this post. So you will need to either:

    • Implement this solution in the XSN that was used for all the completed InfoPath XML forms and open each one and  submit the form to the list
    • See if there is some type of SharePoint code solution that you could implement to enumerate each of your completed forms, pull out the relavant data and create list items of that data. I would think there is a way you could do this using the SharePoint object model but this is not my area of expertise. I would suggest you pose this scenario to one of the SharePoint groups.

    Scott

  • jchavezb says:

    Hi Scott

    sorry for my english … but i’m learning :0)

    well the example is running now but i need to made this with a choise option, it’s is possible? or with data type date? because i’m try and i can get it…

    thanks a lot for any orientation …

    Best Regard.

    Javier

  • infopath says:

    Hi Javier,

    I am able to use both a "Choice" and "Date" field in my list. Here is how I tested with a new list:

    • Created a new list named: ChoiceAndDateTest
    • Added 3 new columns to this list:

          – txtName (Single line of text)

          – txtChoice (Choice data type and set the default options to:

               A

               B

               C

          – txtDate (Date and Time)

    • Modified my Add List Item Template XML file to the following:

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="txtName"></Field>

           <Field Name="txtChoice"></Field>

           <Field Name="txtDate"></Field>

       </Method>

    </Batch>

    • Updated my "ListName" node in my data source to use the GUID for this new list
  • Previewed the form and entered the following data:

        – Title: Test1

        – txtName: Scott

        – txtChoice: A

        – txtDate: 2009-01-05

  • Submitted the data and it was correctly added to the list.

  • Can you try these steps and let me know the results?

    Scott

  • jchavezb says:

    Hi Scott

    this work perfect !!! :0)

    thanks a lot!! for test was fine…  

    Well now i’ve problem when made my real development because i’m trying to do a form with 12 question (choises ) and 12 observation … and can´t get it ..!! they don’t show any error but my sharepoint list will don’t  updated!!!

    is possible to catch an error in the comunication between my application and sharepoint ???

    May at this point

     <Batch OnError="Continue"> –> I don’t want to continue, i need to know the error !! is this possible???

    Thanks a lot for your help…

    Javier

  • jchavezb says:

    Scott

    I think the big problem is the name in the field of the list (in sharepoint) because i try with two kind of names :

    P.e :

    • P1 –> don’t work and don’t show any error, but my list is not updated…
    • a –> Work!

    :s is very odd but if i change just the name’s all work perfect …mayby by the way is working webservice ???

    Best Regard

    Javier.

  • infopath says:

    Hi Javier,

    I am certainly glad to hear you were able to get it working; however, I agree – it seems odd that a field name of "P1" does not work. I am assuming that your XML file has the field specified as "P1" and not "p1" – correct? Also – one thing you may want to do is put the field back in SharePoint as P1, recreate the connection from within InfoPath, save out the files from the XSN (File -> Save As Source Files), open manifest.xsf with Notepad, find that SharePoint connection and make sure that field is indeed coming through as "P1". I have seen one case where a customer specified a field name for their column and for some reason the actual name in SharePoint was something different.

    Scott

  • jchavezb says:

    Hi Scott

    I am assuming that your XML file has the field specified as "P1" and not "p1" – correct? –> Yes ! i know that XML is Case Sensitive… so i’m using the same name for both!!…

    I have seen one case where a customer specified a field name for their column and for some reason the actual name in SharePoint was something different. –> Finally i’m delete both files (List and Form) and try again and OPS! don’t show any error but still don’t update my list… so i went to the path of the manifest and effectively the name in the sharepoint list is diferent ….

    Why this happen ? i think is a bug of sharepoint…

    So now i’m trying again deleting both files… but is some tired to do .. because for made a simple form spend so much time.. because if I make a mistake i’ve to do everything again :0(

    Maybe this kind of feature is better not be implemented between sharepoint and Infopath …

    Well i will comment my hard way to get this ….

    Thank’s a lot again …

    Javier

    Ps : I’m thinking in traslate this article to spanish and Portuges, when will be done i tell you…

    Best Regard…

  • infopath says:

    Hi Javier,

    I am not a SharePoint expert so I am not sure why the actual name is sometimes different. You may want to post that question to a SharePoint blog and see if you get any insight. However, in the future, once you create your SharePoint list you simply need to insure the XML file contains the same names exactly as they appear in the manifest so a "quick" step is just extract the files from the XSN, open the manifest and verify the names. Then simply make sure your XML file matches what is in the manifest.

    Scott

  • jchavezb says:

    scott

    hi look :

    <xsf:field sharepointName="b" infopathName="b"></xsf:field>

                    &lt;xsf:field sharepointName=&quot;bo&quot; infopathName=&quot;bo&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field sharepointName=&quot;_x0063_&quot; infopathName=&quot;c&quot;&gt;&lt;/xsf:field&gt;
    

    i don’t know why the name of this field "x0063" if in the list is declared like "c" …

    Best Regard…

    Javier.

  • jchavezb says:

    Oki doki scott i will post to a sharepoint blogger  this issue …  thank again for your usefull help…

    Javier

  • jchavezb says:

    ok scott finally i get the problem was the manifest because this don’t update when i change the list on sharepoint for this reason, for example when change a name field on sharepoint the name in the manifest still have keeping  the previous name.

    So for example :

    if i created a list with "MyList" with a field name P1 and after then i change the name to "Foo" when i try to execute again my form this don’t show any error but "MyList" is not Updated…

    should not change the manifest if the list be amended?

    the manifest keep on cache???

    Well my counsil for another peopple that have the same problem is "All the time verify the manifest name’s, and if you change a field on the sharepoint list" you should delete the references until both name be the same…

    I don’t know if you understand but the key for this work is just this…

    Thanks a lot i hope this help to someone…

    Javier.

  • infopath says:

    Hi Javier,

    After you change a field name in your SharePoint list are you updating the connection in InfoPath? If not, this would be the expected behavior. If you make a modification to the list schema (i.e. add/delete a field, change a name, etc.) you then need to complete these steps in InfoPath:

    • From the Tools menu choose Data Connections
    • Select your list data connection and click Modify

    • Complete the wizard all the way through and now any change you made should be reflected in InfoPath

    Scott

  • jchavezb says:

    Hi Scott

    i not make the update just delete the conection to the list and then created a new conection follow the wizard , but still this doesn’t work…

    At this moment i’m fix this just looking with so much patience all the name’s and is working now!! :0)

    But for get this all the time was create my list on charepoint – create the conection – see the manifest – when the name’s on both sides , when the name were the same – all run perfect… in fact now is working without problem…

    for me the problem is with sharepoint or maybe if InfoPath keep a copy on cache … for example on this case :

    <xsf:field sharepointName="x0063" infopathName="c"></xsf:field>

    On my local XML the name were "c" .

    in the list also "c" but how you see on manifest has "x0063" , i try deleting the list (don’t work, the behavior was the same).

    finally created other list and then work… i know is odd but is the only way that get this run …

    Best Regard.

    Javier.

  • brynnie5209 says:

    Hi Scott,

    First of all, I’ve read through all the postings in this blog and you really know your stuff!  I’ve created a form that submits directly to a SharePoint list, which is great– solves a problem I’ve been working on for weeks!

    Now I’m trying to modify my form so that it auto-populates the fields from another view within the same form… basically, I’ve got one view in which users input a bunch of data (which will submit to SharePoint using the regular method), but I’ve created a second view with your solution, and would like to update columns in a separate SharePoint list based on input the users entered in the first one– without making them have to switch views or input data a second time.

    I thought that after creating the second view with the repeating tables, as per your instructions above, that I could set the default value to equal data from other fields in my first view– obviously, it doesn’t seem possible to do this.  

    Any idea how to set a default value for the fields your tutorial has helped me create?  My Add List Item Template looks like the following:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="Group"></Field>

           <Field Name="MTSTeam"></Field>

           <Field Name="ProjectManager"></Field>

           <Field Name="PercentOfOverallWork"></Field>

    &lt;Field Name=&quot;PriorityOfWork&quot;&gt;&lt;/Field&gt;
    

       </Method>

    </Batch>

    But I’d really love to be able to autopopulate those fields with data already entered into the form (OR, figure out how to get the other fields in the first view to populate columns in my SharePoint list without the need for a repeating table, etc.).

    Any ideas?  Is this possible?  Or am I out of luck?

    Thanks again– this post has been fabulous!

    Brynnie5209

  • jchavezb says:

    hi Brynnie5209

    i’m made some like you but not with autocompletedata, i’m make an WorkFlow that after send the form to the list the list display the data input and data from another list (with a workflow in Sharepoint Designer that can update a List when new item is added)…. now if you want to get data from a list this perhaps can help you http://cs.vbcity.com/blogs/skullcrusher/archive/2008/12/16/get-list-of-site-users-in-infopath-form.aspx</a“>1…

    I hope this help you ….

    Best Regard

    Javier.

  • jchavezb says:

    Hi Scott

    Me again i need some more orientation .. i’m trying to publish my form and i need enable the feature "Open in Browser" but i can’t get it because in all forum’s say that i’ve to remove my C# code….

    This for me don’t make sense … do you know if exist a way to publish with C# code and enable the compatibility to open in a Browser ???

    Is this possible??? or just am forced to take the client installed InfoPath???

    Thanks a lot for any orientation… i will try …

    Bye Best Regard ..

    Javier

  • infopath says:

    Brynnie5209:

    Using the method described in this blog post, you cannot auto-populate those fields. There is another way to do this (without code) but it is an "InfoPath Client Only" option (in other words, it will not work in browser forms) and would require somewhat of a re-design of your XSN. If you would like to pursue this, let me know and I will provide you with the steps.

    Javier: Yes – you can publish an XSN with code for browser use – you just have different steps to follow…take a look at this information:

    http://msdn.microsoft.com/en-us/library/bb267337.aspx

    Also – in the future, please keep all comments and questions specific to the blog topic.

    Thanks!

  • brynnie5209 says:

    Scott,

    That would be amazing, if you were willing to provide the steps– I tried to re-work one of the code solutions you provided for auropravin (who wanted to add a date picker, rich text field, etc.) by entering blank text fields, setting the default, and then tweaking the code you provided to him– made a total muck of it, of course, as I’m more of a "no code solution" kind of girl.  

    Please let me know if there is other information I would need to provide for you; the infopath form I’m using isn’t browser-enabled (I was willing to decrease functionality and make it browser form to use your original solution, so I’m thrilled if there’s a way to solve for what I’m trying to do without changing a lot of the rest of my form; even MORE thrilled if I don’t have to use code).

    Javier, thanks for the suggestion– the link you posted was helpful for another project I’m working on!  

    And thanks again Scott for your quick response and willingness to teach me something!  

    v/r,

    Brynnie5209

  • infopath says:

    Hi Brynnie5209,

    Here are the new steps – and again these will only work using the InfoPath client. (NOTE: I would suggest you first create a new sample XSN to make sure this works and then implement this in your actual XSN.)

    This update will still follow the same basic steps outlined in this blog post except for step #7.

    • Complete steps #1 – #6 in the original post
    • For step #7, implement the following:

          o Right-click on the root “myFields” and choose Add

               * For Name, enter: gpContacts

               * For Type, select: Group

               * Click OK

          o Right-click on “gpContacts” and choose Add

               * For Name, enter: _Title and click OK

               * Repeat the above line adding: _FirstName, _LastName, _Email and _Phone

          o Drag “gpContacts” to your View as: Section with Controls

    • From the Tools menu choose Submit options

    • 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: Set a field’s value

    • Click the Select XPath button next to Field

          o From the Data Source dropdown box choose: Add List Item Template

          o Drill down, select the “Field” node and click OK

          o Click the “fx” button next to the Value field

               * Click Insert Field or Group

               * Select the Main data source

               * Drill down through gpContacts, select: _Title and click OK

               * Click OK until you are back to your form template (NOTE: This was just a “sample” rule to help complete the next steps)

    • Save the changes to your XSN

    • Create a new folder on your computer called: SourceFiles

    • From the File menu in InfoPath choose: Save As Source Files

          o Select the SourceFiles folder created above and click OK

    • Close completely out of InfoPath

    • Navigate to the SourceFiles folder, right-click on manifest.xsf, select “Open with…” and open this with Notepad

    • Locate the following node in the file: <xsf:ruleSets>

    • Directly under this node, you will see the “sample” Rule that we created above as follows:

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

    • Copy this entire line, scroll to the end of this line, hit Enter and paste this again
  • Repeat the above step three more times so you have a total of five lines that have the same information (the number of lines you have here correspond to the number of fields in your Add List Item Template.xml file)

  • Add an “index” to each “Field” node, like this:

  • <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field[1]" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

    When you are done you the index number should be incremented for each "field" (i.e. [1], [2], etc.)

    For each line, change: my:gpContacts/my:_Title to point to the correct node that we added (i.e. _Title, _FirstName, etc.)

    NOTE: It is very important that your “expression” nodes are in the same order as what you have in your Add List Item Template.xml file. In this sample, “Field[1]” is Title, “Field[2]” is FirstName, etc. Also – like all XML, capitalization must also match what you have in your data source.

  • Right-click on manifest.xsf but this time choose Design (this will open in InfoPath)

  • From the File menu choose Save As and save this as your original XSN

  • Now we need to complete the “submit” option

        o From the Tools menu choose Submit Options

        o Click Rules

        o Select our Rule and click Modify – you should now see each of the lines that we added in the manifest and each will be "indexed".

        o Select the last entry in the Rule and click Add Action

        o From the Action dropdown box choose: Submit using a data connection

        o Select your Web Service Submit connection and click OK

        o Click Add Action

        o From the Action dropdown box choose: Query using a data connection

        o Select the “MyContacts” data connection and click OK

  • Click OK until you are back to your form template

  • Click Preview

  • Fill in the new fields and click Submit on the Toolbar – the data should be populated in your list!

  • A couple of points:

  • If you create a “DateTime” column in your SharePoint list, do not create that node in your main data source as “DateTime” – it must still be created as “Text (string)”

  • I hope this process works for you!

    Scott

    Reply
  • Jamz says:

    Hi Scott,

    Thanks for this great tutorial! It worked a treat for me. My problem is styling.

    Im currently doing a company project for user requests, and hopefully my form will get passed around all the managers in the company. Now if i gave them the above, i dont think they would be very happy with just a list of forms which didnt really mean much to them.

    What I’m after at the moment is a InfoPath form which just submits to the list (wont be displaying any information from the list in the form) which is basically what you have above. But i would like to design my own form, and not have the form output from the list.

    Is there any way to do this?

    Cheers

    Jamz

  • infopath says:

    Hi Jamz,

    I am not sure I completely follow what you are asking; however, the only reason I include the list items in this sample is just so you can see it was added. There is no need to have the existing items display on the XSN. In regard to form design, using this blog limits what you can do; however, take a look at my prior response to Brynnie5209 – this is a different way to design the XSN so you have more control over formatting; however, this will not work in the browser unless use code, which means you really don’t need anything from this blog post. 🙂

    Scott

  • jchavezb says:

    Hi Scott

    Is just for thank you for the help i’m finish my prototipe and everythinks is running Ok !

    So see you the next time….

    Best Regard.

    Javier.

  • infopath says:

    Hi Javier,

    I am glad to hear everything is working for you!

    Take care,

    Scott

  • brynnie5209 says:

    Scott,

    Just had to write back to THANK YOU for the wonderful help– your solution worked like a charm, and I’m now able to do so much more with the data my team submits.  This solves a problem we’ve been trying to work out for months, and I can’t tell you how refreshing it’s been to have someone help you solve a problem while simultaneously teaching you something along the way.  Thank you again; I really appreciate it, and look forward to reading more of your posts in the future!

    v/r,

    Brynnie5209

  • infopath says:

    Hi Brynnie5209,

    That is great to hear – thank you! 🙂

    Scott

  • jchavezb says:

    Hi Scott:

    I’m here again so i’ve another problem :0( , once i test my aplication on my computer connect to the server all is ok … but i’ve a Virtual machine like server and there i’ve one user by default and when this user try to send the form , appears this message:

    at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)

      at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()

      at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()

      at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

      at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

      at MS.Internal.Xml.XPath.ChildrenQuery.Advance()

      at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()

      at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)

      at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)

      at SataFinal.FormCode.Btn_Submit_Clicked(Object sender, ClickedEventArgs e)

      at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)

      at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    But if send from my pc all run right … you know can happens??? why this behavior??? may be i’ve to do some more configuration ????

    Thanks a lot for any orientation…

    Javier.

  • infopath says:

    Hi Javier,

    There is probably more to this error message but it appears it is failing when submitting the data. You may want to check the following items:

    If you need more assitance troubleshooting this, you may want to open a support case to dig into this further.

    Scott

  • jhill@ppc.com says:

    Hi, Scott – the meeting minutes form is working beautifully for us, but of course now the CIO wants to spiff it up by automatically retrieving agenda items that are posted to another list in the same site.  I configured the data connection to retrieve the fields that we need; however, there is a Notes column (Multiple lines of text) in the list that does not appear in the list of available items to select when creating the data connection.  The other columns are "selectable" and appear just fine in the form.

    Is there any restriction on this type of column? Thanks for any suggestions.

    Jan

  • infopath says:

    Hi jhillppc,

    Correct – some data types are not available via the list connection like this; however, you should be able to get all the columns using the method described in this blog post:

    Populating form data from SharePoint List Views

    http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

    Scott

  • jhill@ppc.com says:

    Hi, Scott – regarding the VS code that submits to the Sharepoint list–there are two fields that the requestor initially completes and then submits the form.  Our group opens the form and completes other fields to be submitted to the list.  That works fine, but I’m trying to determine how to add the two fields that the user submitting the form completed to the same list–is it possible to add to the submit code or do we need another data connection?  Being programming-challenged, I don’t know the syntax to test.

    Here’s a line adding one of the fields from the secondary data connection:

    xnAddServer.SelectSingleNode("/Batch/Method/Field[@Name = ‘Host’]", ns).SetValue(xnMain.SelectSingleNode("/my:serverRequest/my:svrInfo/my:_VMHostIP", ns).Value);

    I want to add "Requestor" and "Project" from the Main data connection.

    Thanks and have a great weekend.

    Jan

  • infopath says:

    Hi Jan,

    You should not need to add a new connection; however, to "update" an existing list item you will need to be sure you have that items "ID" value. So be sure this field is in your data connection. Then you should be able to add those two new fields to the data connection and implement the same basic code.

    Have you tried this approach yet?

    Scott

  • jhill@ppc.com says:

    Hi, Scott – added "ID" to the addserver.xml; and to the secondary data connection, so now ID, Project and Requestor appear in the secondary data connection.  The two additional lines have been added to the code.   Form published and uploaded on the Sharepoint applications, Manage Form Templates site.  A new form loads and can be properly submitted.  

    BUT, when trying to update the form, then submit to the list, I get "An entry has been added to the Windows event log…Log ID: 5337."  Haven’t found much on this error, but that’s where I’m at, down here in the deep end again.

    Thanks for the info.

    Jan

  • infopath says:

    Hi Jan,

    What you will probably need to do at this point is step through your code to make sure everything is working as you expect, variables are set to the correct values, etc.

    If you need more assistance with this it may be better to open a support case so someone can work with you 1:1 to help debug the problem.

    Scott

  • lokeshd says:

    hi Scott,

    Thanks for the article.

    I followed the steps described in this article. When I click submit I get the message saying "This form was submitted succesfully". But there is no new item in my contacts list.

    I found

    Soap error: Unspecified HTTP error..

    Event Xml:

    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;

     <System>

       <Provider Name="MSSOAP" />

       <EventID Qualifiers="49152">16</EventID>

       <Level>2</Level>

       <Task>4</Task>

       <Keywords>0x80000000000000</Keywords>

       <TimeCreated SystemTime="2009-03-23T13:20:30.000Z" />

       <EventRecordID>868</EventRecordID>

       <Channel>Application</Channel>

       <Computer>BDMWS-02.sunplusdata.com</Computer>

       <Security />

     </System>

     <EventData>

       <Data>Unspecified HTTP error.</Data>

     </EventData>

    </Event>

    please specify the solution for this error :

  • infopath says:

    Hi lokeshd,

    There are a number of comments in this blog on the exact behavior you are seeing. I would encourage you to read through all of these as you will get insight on what to check but here are a few of the more common reasons you will see that behavior:

    ** I would suggest you do the last bullet anyway just to be sure the names coming from SharePoint are exactly what you think they are and have specified in your XML file.  Once you extract the source files, open manifest.xsf with Notepad and then look for the "xsf:sharepointListAdapter" node – below this will be the actual field names as they come from SharePoint.

  • bawcior says:

    Awesome! I had a lot of problems getting this to work and it turns out the column names were not what I was thinking they were. One way to check your column names as they appear in web services is to click on column name in the list and then look at the last field, for example:

    http://somesite/_layouts/FldEdit.aspx?List={58E78B34-EE26-4E5F-BC7D-A4F8189775F8}&Field=E_x002d_mail_x0020_Address

    In this case my column name was E-mail Address which resulted in E_x002d_mail_x0020_Address

    I haven’t read all the comments yet. What about Data validation, how can that be done (the easier the better)? Let’s say I want to have e-mail field and confirm email fields and check if they are both equal (using Infopath rules to do so would be preferred) And also what about better formatting for the fields and making the form look good?

    In any case, this is great. I used this to get aroung anonymous submission problem (since anonymous users can add items to the list, but not libraries)

  • infopath says:

    Hi bawcior,

    I am glad to hear you were able to get the process to work! 🙂

    In regard to your other questions, we need to keep the blog posts specific to their topic so I am not going to go into a lot of detail.

    abc@hotmail.com

    abc@hotmaiL.com

    Scott

  • ElenaS says:

    Hello Scott!

    Thank you so much for the solution.

    I have a related question for you, however. In the revolving table from the Batch data source, how can I make the entries multiple choice?I know I can change the cell to a Drop Down list, but how do I get the drop down values to be individualized for each cell on the Preview side?

    I thought I could instead build other cells in the forms data source and make those multiple choice and have the information in the Batch revolving table feed from those cells, but I still do not know how to separate each individual entry. Does my question makes sense?

    Thanks!

    Elena

  • infopath says:

    Hi Elena,

    This is how I am interpreting your question: when you follow the steps documented in this post, all of the fields to be completed show as basic text boxes. What you would like to do is have one or more of those be dropdown boxes – is this correct?

    If so, then the way to do this is documented in my response to a user on 1/9/2009 in this post. However, it is important to know that this option will only work for forms you will be using in the InfoPath client. If your XSN is designed for both the client and the browser, then you would still need to make the basic design as I documented on 1/9/2009 but you would need to use managed code to populate the XML file used for the list update. (In other comments in this blog, I have provided code to perform the updates.)

    Scott

  • bawcior says:

    I want to set some of the fields that are being submitted to SharePoint  to some value (not user typed). How do I do this either in InfoPath or C#? Thanks

    Pawel

  • infopath says:

    Hi Pawel,

    Take a look at my response on November 18, 2008 – there is sample code there and part of that is setting values in the XML file.

    Scott

  • jborean says:

    My goal is to have an InfoPath form submit fully to SP list… not just set up column data.

    If it is submitting to a SP list… where does it get initiated from? Could we use a document library to initiate the form and have it submit to a list and not to the library at all (effectivelly just using the document library to pull up the template)?

    I plan on using qRules to submit attachments to a SP list to reduce the load time of my InfoPath form. It would be my dream if I could call up an InfoPath form and then submit the form and attachments (seperately) to a single item on a list.

    v/r,

    Jason Borean

  • infopath says:

    Hi Jason,

    I am not sure I fully understand what you are asking. From an InfoPath perspective, out of the box you can submit to a SharePoint "library", which means the entire form gets sent to the library as a document. You can submit the form "data" to a SharePoint "list" but this is not available out of the box (hence this blog) but only submits the data in the form (and in the columns you specify) to the list.

    So in this case, your question of "where does it get initiated from" – that would be from InfoPath. In addition, to include submitting an attachment – that would be a separate web service call to the list item because this needs the list item ID, which we would not know until the data has been submitted to the list and the item created.

    In regard to your question of submitting to the list and not to the library – sure…this can certainly be done. If you follow the steps in this blog, you would only have one submit connection, which would be to the list. So although you may be "publishing" your InfoPath Form Template (XSN file) to a SharePoint library, you do not "have" to submit to that library. This may simply be the point to which a user launches the form, fills in the data and then clicks Submit…which may only be to your list.

    I hope this helps!

    Scott

  • amod_goyal says:

    Hello Scott and all the developers,

    Great post. Used InfoPath 2003 to populate data to SharePoint 2007 list. Can you help me with your ideas or direct me to a blog/URL for the following.

    Two major areas where I am getting freezed up:

    1. Instead of using CAML template, if I create  form design in Infopath directly and then I want to submit the data to list? Since my form is pretty big with different type of controls including combo, text box, tease area, date, file attachment and they get displayed according to combo box selections. Please suggest a way for this or other ideas around this.
    2. Since I have a file attachment control, that needs to be attached to the item in the list, you mentioned in your previous reply that "it needs to be a separate web service call to the list item because this needs the list item ID, which we would not know until the data has been submitted to the list and the item created". Can you please me direct me towards that solution.

    Thanks in adavnce!

    Ami

  • infopath says:

    Hi Ami,

    I am not sure I follow what you are asking in question #1. Are you asking how you could submit your data to a list without using the CAML XML template? If so, then the only way to do this would be to use custom code – in the code you would basically be creating the CAML expression to send the data to the list. If this is what you are asking, take a look back through the comments on this blog as I have provided sample C# code on how to to this basic process.

    In regard to question #2 about adding an attachment – you would need to use custom code to extract the contents of the attachment (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;892730) and then make a call to the AttAttachment method of the "lists" web service to upload the extracted file contents to the list (http://msdn.microsoft.com/en-us/library/lists.lists.addattachment.aspx).

    Scott

  • zhangweisjz says:

    How to retrieve data from SharePoint List using InfoPath 2003

    Hi Scott, I have been troubled in this question for a long time. My request is this:

    Say there is a SharePoint website on my domain, and I have admin rights to the website but have no write access to the SharePoint Server. I want to design a infopath 2003 form, with 2 or 3 textboxes, one search button and one repeating table. When I type in the textboxes the search words, and then clicking button, the repeating table will display the values retrieved from SharePoint List.

    Please do me a favor to give me a detailed guide! Thank you very much!!

    PS: I have the environment to write managed code(VS2003 and Infopath SDK) , but there is a small problem: I can not using Microsoft.SharePoint.dll, what’s the reason for this? Is this because I don’t have Windows SharePoint Service 3.0 installed on my OS windows XP professional?

    Thanks again!!

  • infopath says:

    Hi zhangweisjz,

    You will need to use code to do this but it is relatively simple. I would suggest using the method described in this blog post to create the data connection to your list:

    http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

    The reason is we can easily append "filter fields" and "filter values" to the URL which will be used to only return back the records that match your search criteria.

    The following is how I setup my sample:

    1) SharePoint List:

        – Column Name: Alias (single line of text)

        – Column Name: WorkedFor (single line of text)

    2) I have two records in my list:

        – Alias: sheim, WorkedFor: jasperh

        – Alias: joelall, WorkedFor: tabb

    3) Here is the main data source in my XSN:

    myFields

        txtAlias

        txtWorkedFor

    4) Added a data connection (called: GetListItems) to my list using the above referenced blog (NOTE: I just did the first few steps and make sure you review the "Caveats" comments. I did not do anything in the "Some tricks" area…these I do in code. <g>)

    ** Make sure you uncheck the option to retrieve the data when the form loads – we don’t need to do this.

    5) Added my two fields a button to the view and the repeating "z:row" (from the secondary data connection) to my View as a Repeating Table

    6) I have the following code on my button click event:

    //Create IXMLDOMNode objects for my search fields

    IXMLDOMNode nodeAlias = thisXDocument.DOM.selectSingleNode("/my:myFields/my:txtAlias");

    IXMLDOMNode nodeWorkedFor = thisXDocument.DOM.selectSingleNode("/my:myFields/my:txtWorkedFor");

    //Create an int variable to increment the "filter field" and "filter value" number

    int i = 1;

    //Create an XMLFileAdapterObject for my XML (SharePoint list) data connection

    XMLFileAdapterObject dList = (XMLFileAdapterObject)thisXDocument.DataAdapters["GetListItems"];

    //If the "txtAlias" field is not empty then append this to the search value to the URL

    //and increment the field counter

    if (nodeAlias.text != string.Empty)

    {

    dList.FileURL += &quot;&amp;FilterField&quot; + i + &quot;=Alias&amp;FilterValue&quot; + i + &quot;=&quot; + nodeAlias.text;
    
    i += 1;
    

    }

    //If the "txtWorkedFor" field is not empty then append this to the search value to the URL

    //and increment the field counter

    if (nodeWorkedFor.text != string.Empty)

    {

    dList.FileURL += &quot;&amp;FilterField&quot; + i + &quot;=WorkedFor&amp;FilterValue&quot; + i + &quot;=&quot; + nodeWorkedFor.text;
    
    i += 1;
    

    }

    //Now, query the connection

    dList.Query();

    What this code will do is see if any of your "search" fields (txtAlias and txtWorkedFor) contain values – if they do, the code appends the "FilterField" and "FilterValue" pieces to the URL (along with the appropriate counter value) and then executes the connection.

    I hope this helps!

    Scott

  • zhangweisjz says:

    Great Great Thanks!

    Hi Scott,

    I can say nothing but thanks for your great great help! I followed your guidance and it really works! Althrough I am in distant China, I was touched by your kindness.

    But I a little greedy that I have two other relevant questions, please help:

    1, How can I make foggy search (or say as T-SQL "like" function, in your example — Alias: sheim, WorkedFor: jasperh, when you input "she" in the form, the result "Alias: sheim, WorkedFor: jasperh" can also be displayed). How can I make this feature?

    2, How can I update the value of result? Let me take "Alias: sheim, WorkedFor: jasperh" for example, if I change sheim to zhangweisjz, and click a button, the valued is submitted by the SharePoint List. (I don’t mind the way of writing code to solve this problem)

    3, When creating a form in SharePoint form library, user will have to save the form and type in a certain name. Could we have a function that form can generate a random string as its name when saving?

    Thank you very much!

    PS: I made a small modification of your codes, so that we can search more than once:

    string tempURL=dList.FileURL;

    if(nodeAlias.text!=string.Empty)

    {

    dList.FileURL+="&FilterField"+i+"=Alias&FilterValue"+i+"="+nodeAlias.text;

    i+=1;

    }

    ……

    dList.Query();

    dList.FileURL=tempURL;

    I dare not show my poor programming skills to a master, but to make it simple to use if someone also needs to make this kind of function.

  • infopath says:

    Hi zhangweisjz,

    I am glad you were able to get the sample working!

    In regard to your other questions:

    #1: I am not a SharePoint expert but I don’t know if there is a way to implement "fuzzy" searching as I don’t believe SharePoint suppports (by default) wildcard searching. This may be better posed to a SharePoint blog.

    #2: You can use the methods described here throughout the comments to update the list. You can either use the XML Resource file method or simply build the CAML query in code and perform the update. Now – you can place a button control in a new column in your repeating table and this will allow you to update just the values in that row or you could use a button outside of your repeating table and use code to loop through all the rows and update the values.

    #3: Instead of using the built-in Save, create a "Submit" data connection. This way you can use formulas and/or fields from your form to create the file name.

    Scott

  • brynnie5209 says:

    Scott,

    Once again I want to thank you for the help you gave me back in January to enable my InfoPath form to auto-populate fields (and therefore users to input data from different types of fields [date boxes, drop-downs, etc.]) before submitting to a SharePoint list.  The solution you helped me with has been so popular, in fact, that I’ve been asked to use the method again to create a different type of form for my group, which leads me to another opportunity to pick your brain, posted below:

    I’ve been asked to create an InfoPath / SharePoint solution which will enable users in our group to submit “tokens” to other employees in our organization as a thank-you/atta-boy.  Each FTE starts the year with 100 tokens to give out to others, and at the end of one year awards are given out to employees who have achieved certain levels of received tokens.  My InfoPath form enables users to nominate someone for a token, and the data is then (successfully, thanks to you) submitted to a SharePoint list which tracks all of the nominations.  The other part of your solution is applied when a user opens up a new form—the InfoPath form pulls the SharePoint list data into the table that’s created in my form (step 5 from your original instructions), and I’ve used sum and counting functions within this table to track how many tokens the user has submitted, received, and (with a little bit of math) has remaining to give out.  

    This works like a charm in my testing environment (i.e. submitting to a blank SP library with new data), but I’m creating this solution as a 2nd version to an old method, which means I will be working off a SP list that has 7000 rows once I migrate all the archived token data into my created SP list.  This is (obviously) causing me a number of problems, including:

    1. Item limits in the SharePoint list—I’ve configured the list view to show all items, which works fine in SP but still doesn’t manage to pull all of my rows to my InfoPath form to enable the token-counter function I’ve created.
    2. Even if I cleaned up the archive so that the list started with less rows to track and did some manual work to keep the SP library from getting too big, I’m noticing that anything over 500 rows in my SP list causes my InfoPath form to open VERY slowly.

    My question, after all that build-up, is this:

    I know you mention in your original posting that you can configure the InfoPath form to NOT pull list data back into your form, but I need that data in order to perform the token-counting functions I’ve set up.  Is there any way to pull the SP List data in such a way that, rather than individual rows, the data I pulled from the SP list I’m sending to could either be consolidated in some way so that my form doesn’t get too unwieldy, OR is there a way to configure my form to only pull data from specific COLUMNS in the list?  I’m hoping that one of these options may enable the functionality I’m trying to achieve without causing the form to hang while opening and still enable the token-countdown function I need to complete my solution.

    I’m hoping this is still considered on-topic for your blog posting; I know I’m touching on a couple of other areas (SP Item Limits, etc.), but I’ve tried a number of other ways to achieve the same outcome with no success.  Any thoughts on whether or not I can enable token-counting using the method you’ve outlined in this blog would be greatly appreciated.  Thanks again!  

    Sincerely,

    Brynnie5209

  • infopath says:

    Hi Brynnie5209,

    I am glad to hear things are working well!

    In regard to your new questions:

    1) Showing all items in InfoPath:

        – Navigate to your list

        – Select the "Modify this view" option from the View dropdown (make sure you are showing the default view)

        – Expand the Item Limit option

        – Select the option "Limit the total number of items…" and then set the number to something larger than you think you will need (i.e. 10000)

    2) Amount of data returned

        – If you complete the above steps, your form will get even slower <G>

        – As you have seen returning large amounts of data to an InfoPath form will cause it to slow down drastically. I am not going to go into here all the reasons why but you will really need to limit the amount of data you return. So – some things you can look at trying:

    http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

    Scott Heim, 50 tokens remaining

    ** This assumes that you don’t have 7000 rows corresponding to 7000 employees. 🙂

    I hope some of this helps!

    Scott

  • jhill@ppc.com says:

    Hi, Scott – hope you’re doing well.  Thanks again for your expertise in solving our problems with Infopath and our Meeting Minutes a few months ago.  I’ve been tasked with setting up another list for submitting help desk requests, and created the list from the Help Desk application template.  Of course some modification of the list was required by adding a few columns, and the editform.aspx and dispform.aspx had to be modified to accomodate the new columns.  The "Comments" field was left as is–columnwise and on the forms–and data can be entered the first time a list item is edited.  If someone needs to go back to the item to add more comments, any previous entry appears in the dispform.aspx, but disappear when the editform.aspx opens.  All other fields remain populated.  I’ve verified that "@comments" is referenced in the table on both forms, and can view the data using "show data values."  Just another one of those SP gotchas?  Any thoughts other than trying to recreate the Comments field?  Thanks much.

    Jan

  • infopath says:

    Hi Jan,

    Glad to hear all is going well! 🙂

    The editform.aspx and dispform.aspx are the built in SharePoint forms used to view and update list items – correct? If so, I don’t have enough SharePoint expertise to understand why this occurs. If you can tell me where you downloaded the Help Desk template, I can try it on my side to at least see if I get the same behavior.

    Scott

  • jhill@ppc.com says:

    Scott – I found it at http://www.microsoft.com/downloads/details.aspx?FamilyId=CE90D6D7-7B96-47BF-A22F-A7E8C5D40647&displaylang=en

    Please don’t spin your wheels too much on this…I can try deleting the column and re-adding as a last resort.  Thanks for your quick response!

    Jan

  • infopath says:

    Hey Jan,

    Thanks – as this appears to be solely a SharePoint application, I’ll let you see what you can find. If deleting and recreating the Comments column does not help, it will probably be worthwhile to touch base with one of the SharePoint blogs. Hopefully they can shed some light on it for you.

    Now, if this is something that only appears when using InfoPath, then let me know. 🙂

    Take care,

    Scott

  • zhangweisjz says:

    Hi Scott,

    Sorry to bother you again. These days I am working on InfoPath it is fun but I also got a lot of questions.

    Question1:

    I have a request that can InfoPath avoid user to save a form which has a same value as another one?

    For example,

    A booking car infopath tool,

    If one user has finished his applicaton:

    car number: ‘ABCD’, time: 2009/6/8 8:00:00 to 2009/6/8 12:00:00,

    Another user can not save a template if he filled his application form with the same content:

    car number: ‘ABCD’, time: 2009/6/8 8:00:00 to 2009/6/8 12:00:00.

    Is this possible?

    Question2:

    And going further, is it possible to avoid:

    If the time frame 8:00:00 to 12:00:00 is booked, the application form with the time frame 8:00:00 to 18:00:00 can also be prevented.

    The last question:

    When we save a form, we will have to manually input the form’s name, is it possible that the system will generate  a number (random or other kinds) as the form name?

    Thank you very much.

    Sai

  • zhangweisjz says:

    Our user has another concern about the required *field with empty content still can be sent out to forward to next step.

    Is it possible to solve this?

    Thank you.

  • infopath says:

    Hi Sai,

    In the future please post questions that are relevane to the blog topic.

    1) How to avoid saving a form with the same name?

    > If you are going to use the "save" functionality then the only way to avoid this will be using custom code to see if the form already exists. However, if you use the "submit" feature of InfoPath, you can use fields from your form template, expressions, etc. to generate the form name when it is submitted and when you setup that submit connection, there is an option to either allow or disallow overwriting an existing form.

    2) Avoiding a specific time frame?

    > Off the top of my head, this would require custom code to see what is or is not available. However, this may also depend on your form design.

    2A) See answer to question #1.

    3) Required fields can still be sent out.

    > I am not sure how you are "sending the form out" but if you were to use the submit connection again, you would not be able to "submit" the form until all required fields are completed.

    If you need more assistance with any of these questions Sai it may be more prudent to open a support case so we can take a look at your design.

    Scott

  • zhangweisjz says:

    Hi Scott,

    Thank you for your reply.

    I would like to Share my design to you. Could you please send me a email so that I can get your address?

    Mine is zhangweisjz#gmail.com, please replace # with @.

    Many thanks.

    Sai

  • infopath says:

    Hi Sai,

    Unfortunately I really don’t have the ability to do this as I am in support and need to spend the majority of my day assisting customers that have opened support cases.

    I provide answers and samples on this blog as I have time but to review a design and suggest solutions or changes to that design is something I don’t have the time to do.

    I hope you understand.

    Scott

  • dips23 says:

    Hello , Scott !!

    Thanks for this helpful article regarding submition to sharepoint list .

    i tried this article to submit to list and cheked 4-5 times , but i m not getting data in list after i entre data through infopath form , i get the msessage that tell me that " The FOrm was submitted succefully " but its not inserting data into list , as my form display the data from list , but there is only problem in inserting the infopath form data into list…

    i stuck with this problem since many days could you help me please as soon as possible please !!

    Thanks & Regards ,

    Dipti Chhatrapati

  • infopath says:

    Hi Dipti,

    I know there are a lot of comments to this post but please read through all of these as there were a number of questions about this same behavior and there are numerous reasons why this behavior occurs and I have documented those throughout the comments.

    Thanks,

    Scott

  • dips23 says:

    Hello…

    Thank you very much for your kind reply!!

    But I have followed following steps after reading comments in this blog

    1) Proper GUID for list identification.

    2) I did connection properly for submit and receive type.

    3) I get list web services for appropriate site too.

    4) I checked event log to check errors , but didn’t get any.

    5) Xml file also contain appropriate fields as columns in list.

    is there any testing missing ??? Please tell me so I can get result ASAP.

    Thank You,

    Dipti Chhatrapati

  • infopath says:

    Hi Dipti,

    Here is what I would suggest you review next:

    <xsf:field sharepointName="Title" infopathName="Title"></xsf:field>

    Scott

  • dips23 says:

    Hello Sir ,

    Thanks for your reply !!

    i followed all your steps what you suggested , and the field name of CAML file and manifest.xsf file both are exactly same , but i found one mistake in my CAML file

    that should be as follow…

    <?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>

       </Method>

    </Batch>

    here in "  <Field Name="Title"></Field>" , you mentioned single quote around Title !!!

    and i guess jsut coz of this thing people not getting data in list !!!

    i am really very thankful to you that ultimetly i resolve this problem wht you suggested to me !!!

    Thank You very much again 🙂 !!

    Thanks & Regards,

    Dipti Chhatrapati

  • infopath says:

    Hi Dipti,

    Hmmm…that is odd as I re-use the same XML file over and over again for testing and the Title field uses the single quote. So I am certainly glad to hear it is working <g> I am not sure why that would be the issue.

    But as long as it is working…all is well! 🙂

    Take care Dipti,

    Scott

  • Steve Hinkle says:

    I’m an end-user (content administrator), not a developer, so hopefully my question will make sense to you.  My company is implementing InfoPath 2007 very soon and I am wondering if it can work with an existing SharePoint list?  Specifically, will the survey form I create using InfoPath allow the user to edit and overwrite their response (which is already stored in my existing SharePoint list)?  I’d like to be able to use the existing data and not make the user re-input it into a blank SharePoint list.  Thanks for your help.

    Steve

  • infopath says:

    Hi Steve,

    In order for InfoPath to be able to update items that already exist in a SharePoint list, you will need to write code (samples are in these blog comments.) However, since you are asking about a survey you may want to post that question to a SharePoint blog as it may be easier to just use SharePoint features for that. I’m not trying to steer you away from InfoPath but you really would need to know code to update existing items. If, however, all you want to do is "add" the survey responses to an existing list then this post would allow you to do that.

    Scott

  • maxrase says:

    Hi Scott and thank you for this post. Maybe you have already answered to my question but I have a problem.

    Your tutorial works fine and I can send datas to my SharePoint list. But I can’t change the value of the textboxs used to send the form. Indeed, in the XML file, I can only set static value such as

    <Field Name="Title">Test</Field>

    Instead of using a static value (in my example : Test), is it possible to set a value of an other textbox used in my main data source.

    Thanks.

    Maxime

  • infopath says:

    Hi Maxime,

    If you are using the default form design here in this post, then you will need to include the "Title" field on the form so the user can enter the appropriate title. However, if you look further down in the blog comments, I have shown how to re-design the XSN so you can add your own type of fields (i.e. dropdown, date picker, etc.) In this case, you could have another node in the data source, that does not show up on the form unless you want it to, and the value of this node could be an expression based on the other values the user has entered.

    It is important to note that unless you switch the design to use code, the "other" method I mentioned above for the design will only work if you are using the form in the InfoPath client – it will not work for browser forms.

    Scott

  • maxrase says:

    I found a good solution thanks to this post. Scott, do you thing that my form will work with InfoPath Form Services despite the custom code ? Is is considered as Managed Code ?

    Thanks

    Maxime

  • maxrase says:

    Excuse me, I’ve forgotten the link : http://www.bizsupportonline.net/infopath2007/how-to-submit-items-rows-repeating-table-infopath-sharepoint-list.htm

    Maxime

  • infopath says:

    Hi Maxime,

    Yes – this is managed code and the code I have provided here in this post, will work in browser forms as well. However, once you add managed code to an InfoPath Form Template, it changes the way in which the XSN gets published and used in your MOSS site.

    Take a look at this documentation: http://office.microsoft.com/en-us/infopath/HP101000931033.aspx#5 and then this link for the server side steps:

    http://msdn.microsoft.com/en-us/library/ms772405.aspx

    Scott

  • amoghjain says:

    Hi infopath..

    I was able to learn many things from this blog and did implement the contact list successfully.

    now I am trying to do the same thing with a excel file I imported as a custom list. But when I try to submit, i get a confirmation message, and nothing gets added to the list.

    I am not sure but this may be related to the title field, which is not their in my custom list. my list has class, characteristic, and description feilds.

    this is the exact version of the code i am using and i have double checked my GUID and the site(subsite in my case) i am submitting to.

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name=’Title’></Field>

           <Field Name="Class"></Field>

           <Field Name="Characteristic"></Field>

           <Field Name="Description"></Field>

       </Method>

    </Batch>

    looking for you reply,,

    thanks

    amogh

  • infopath says:

    Hi amogh,

    Please be sure to review all the comments in this posting – this issue has been raised a number of times and the suggestions to resolve it are always the same.

    Now, in regard to your "Title" column being missing, I have not tested this before so I don’t know if this is impacting the issue or not. However, even if the Title column exists in the list, it is not "required" to be on of the fields that you include in the XML file to submit to the list. In this case, the Title simply shows as "(no title)" in the list itself.

    Scott

  • dips23 says:

    Hello Sir ,

    i did above task successfully before , but now i am suffering from data validation during submission using your technique…!!!

    is there any way for data validation errors that cannot be submitted until the errors are resolved as when i click on field property for data validation it is showing disable !!!

    then how can i submit data to sharepoint list with exact data validation !!! please help me out !!

    thanks & regards,

    Dipti Chhatrapati

  • infopath says:

    Hi Dipti,

    I am not sure I follow what you are asking – can you provide some additional detail as to what is/is not working?

    Scott

  • dips23 says:

    thanks for your fast reply !!!

    well .. in second repeating table scenario u have shown input data functionality .

    lets say , there is one field " email " ,  i want to apply data validation for email using custom pattern to enter proper value in email field…

    then how can i do that , i hope u wud get my query !!

    thankyou,

    Dipti Chhatrapati.

  • amoghjain says:

    hey infopath,

    I made a new custom list and opened it in excel to edit it. Once in excel i copy pasted all the data I wanted and now, it works like a charm.

    only problem while importing a spreadsheet is, you loose the ID column, which is really important while updating the SharePoint list(atleast according to me :D).

    i still have one more question though..

    is it possible i can assign a feild’s value to a feild in repeating table??? is yes, can you tell me how…

    once again, thanks for all your help and this blog.

  • infopath says:

    Hi Dipti,

    I am assuming you are entering/modifying the email address in the repeating table that is bound to your secondary data connection. As you have seen, data validation is not available through the UI in this case. So there are a couple of options:

    1) Use code to copy all the rows from the secondary data connection to a mirrored data structure in your mail data source (this gives you additional flexibility in UI features.)

    2) Use code on the changed event of the e-mail column from your list to test if the value entered by the user is valid. Here is a Knowledge Base article that provides a basic expression for checking an e-mail address:

    http://support.microsoft.com/kb/308252

    Then you would use code like this in the "Changed" event for your e-mail field in the repeating table:

    NOTE: You will need to add the following "using" statement to your code: using System.Text.RegularExpressions;

    public void MyContacts__Email_attr_Changed(object sender, XmlEventArgs e)

    {

        if (!TestEmail(e.NewValue))

        {

        this.Errors.Add(e.Site, "Email Error", "Error in e-mail!");

        }

    }

    private bool TestEmail(string emailAddress)

    {            

        Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)");

        Match m = emailregex.Match(emailAddress);

        return m.Success;

    }

    Scott

  • infopath says:

    Hi amoghjain,

    Sorry but I don’t understand what you are asking in regard to assigning a value to a field? If you are referring to Excel, then I won’t be able to help but if you are referring to how to do this from Infopath, then please review all the comments in this blog as there have been numerous questions on how to update existing values in a SharePoint list.

    Scott

  • amoghjain says:

    hey,

    i have a secondary data source(New Entry), which updates a sharepoint list with 3 columns(ID, FirstName, LastName). I want to set a default value for the ID column, which depends upon another feild.

    For example, i have a field name "Id_User" in the infopath form, and I want to assign this fields value in the ID field of the repeating table.

    can you tell me how to do to this???

  • infopath says:

    Hi amoghjain,

    Thank you for the clarification. I am not a SharePoint expert but I don’t believe their ID column is updateable. This is an auto-generated value when you add an item to the library or list. If you wanted to generate your own "ID" you would need to create your own "customID" column and this is what you would update.

    If this works for you then you can use the "concat" function in a Rule to set your custom ID column. It would look something like this: concat(<SelectYourField>, "_Test")

    Where "SelectYourField" would be where you use the "Insert field or group" button to select your field and "_Test" could be any text or another field.

    Scott

  • dips23 says:

    thank you very much !! scott !! 🙂

  • amoghjain says:

    here is my code and now i can submit to a repeating table from any feild in infopath..:D(i am a co-op student)

    function CTRL61_15::OnClick(eventObj)

    {var root = XDocument.DOM;

    var Definition_ID = root.selectSingleNode("/my:myFields/my:User_Definition_Modify/my:ID").text;

    var User_Definition= root.selectSingleNode("/my:myFields/my:User_Definition_Modify/my:User_Modified_Definition").text;

    var batch = XDocument.DataObjects["Update Item"].DOM;

    batch.selectSingleNode("/Batch/Method/Field[@Name=’ID’]").text = Definition_ID;

    batch.selectSingleNode("/Batch/Method/Field[@Name=’DEFINITION’]").text = User_Definition;

    XDocument.DataAdapters["Modify"].Submit();

    XDocument.UI.Alert( "Change Request has been successfully saved" );

    }

  • infopath says:

    Hi amoghjain,

    Glad you have what you need!

    Scott

  • bevy31 says:

    Scott,

    I was able to follow you instructions and get the form to work.  My problem or question is, does this form need to be published to SharePoint.  If I save or publish the form to my desktop and try to open the form back up once it is closed, I get the following error:

    "The following DataObject either cannot be created or cannot be initialized: MyContacts

    The query cannot be run for the following DataObject: MyContacts

    InfoPath cannot run the specified query.

    InfoPath either cannot connect to the data source, the service has timed out, or the server has an invalid certificate."

    Can you tell me how to get this to work after you save and close the form.

    Thanks,

    Bev

  • infopath says:

    Hi Bev,

    That is an odd error that I don’t believe is specific to what you are doing in regard to this post. Try this:

    Test #1:

    If the above did not resolve the issue, try these steps:

  • Add a receive data connection to the MyContacts list

  • Display the Data Source Task Pane and drag MyContacts to your view as a repeating table

  • Preview the form and make sure you see the data

  • Save and close the form

  • Simply double-click the saved XSN – what happens? If this works, then proceed with publishing this new XSN to your SharePoint site and test again from SharePoint – what is the result?

  • Scott

    Reply
  • bevy31 says:

    Does the InfoPath form have to be published to SharePoint, or can it be used offline and published to my computer?  Because if it has to be published to SharePoint, then that’s probably why I am getting this error.

    What I am trying to do is submit data to a SharePoint list using InfoPath, but not have the InfoPath form in SharePoint.   Is that possible?

  • infopath says:

    Hi Bev,

    No – the InfoPath Form Template (XSN file) does not have to be published to SharePoint…it can be published to your machine, network share, etc. and you will still be able to update the list.

    Scott

  • bevy31 says:

    I tried both your suggestions and it did not work.  I still get the same message.  It is unable to open the MyContact list once I save the form and close it.

  • bevy31 says:

    I wonder could it be because we have to reach our SharePoint site using a Smart Card.  We have pick a certificate when we login, could this be preventing the retrieval of the list because it is wanting a certificate.

  • infopath says:

    Hi Bev,

    That may be the issue…I’ve not done much with Smart Card logon so I am not 100% sure.

    Scott

  • Nmap says:

    Hi Scott,

    I followed your steps explained in "January 05, 2009" and can successfully submit the data and they show on the Sharepoint list. However the choice fields still show as Text, I need to manually type them while filling the form. Is there any way to choose between from A, B or C like explained in your example. Or I will be also happy if there will be A, B and C and I select them with a checkbox or radio button. Anything other than manually typing them is appreciated.

    Thank you

  • infopath says:

    Hi Nmap,

    Did you follow the steps on January 09, 2009 for "Brynnie5209" ? In order to not get just text box controls for entering data, the design of the XSN will change completely. The steps to Brynnie5209 show how you can use different types of controls in your design. However, there is one caveat to this method: it will not work in browser forms. If you need to use different kinds of controls and the form will be used in the browser, you will need to use custom code for this process…which is also documented in and around this same date to other users.

    Scott

  • emdc2 says:

    If you run through this and have a problem with it not creating a new item in your list . . . even though it says "Submitted Successfully" . . . try this solution: (found at: http://msdn.microsoft.com/en-us/library/cc162745.aspx#ip2007SubmitDataSPList_OverviewofSubmittingDatafromInfoPathForms)

    For the data connection to the Lists Web service to work correctly, the URL you enter must correspond to the location of your MyContacts list. If the list is located directly off the root Web of your SharePoint server, the URL will be in this form:

    http://servername/_vti_bin/lists.asmx

    If the list is located in a site on your SharePoint server, the URL will be in this form:

    http://servername/sitename/_vti_bin/lists.asmx

  • wizardntexas says:

    i have scene this senario everywhere on the net, the problem I have is that it only deals with a textbox type data. how does this caml code apply when your using datepickers in infopath or set up "Choices" in the sharepoint list. I was able to create a sharepoint list based on this approach. Then I expanded to the real world and added dates and logic. interestingly infopath previewed fine. I loaded the form in to the forms side of sharepoint and it ran fine, but did not load the list file. So could you expand this sample to use dates in the sp list and show how to import into infopath. thanks for your time

  • wizardntexas says:

    With infopath you can have multiple "sections" or repeating tables. these may include dropdowns, radiobuttons, text boxes etc. All setup when configuring the list in sharepoint. Is there a way in the caml code to direct the various columns of a Sharepoint List in such away to populate say the address part of the infopath form, and the other columns to the date secton and finally other columns to the list boxes, dropdowns, radio buttons etc? is that what the method id is for? if so how can you steer the code to setup infopath. I expanded on the sample code and it shot off the screen with all the column detail? A page look was more of what i was looking for.

    please advise.

  • infopath says:

    Hi wizardntexas,

    In regard to datetime and choice type columns, take a look at my comments dated September 16, 2008 and January 5, 2009 .

    In regard to your second question, I am sorry but I don’t follow what you are asking.

    Scott

  • gp28 says:

    Hi Scott

    I have a repeating table in an Infopath form comprising of 6 fields.

    4 of the fields are populated automatically from a sharepoint list using the method described elsewhere in this blog.

    The remaining 2 fields are required to be completed by the user and re submitted back to the same sharepoint list.

    One of the fields to be completed is multi line plain text and the other is a status field requiring the user to select from a drop down box.

    Any ideas on the best way to automatically populate the sharepoint list with the additional information contained in these two fields when the form is re submitted. Thanks

    GP

  • PxPx says:

    I have been working on this for 15 hours straight and about to rip my hair out.

    I am unable to submit the form because i get an error saying.

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.

    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Value does not fall within the expected range.</errorstring></detail>

    I am guessing this is because I am trying to map to fields that are not all text boxes.

    New Project SharePoint List fields I am trying to map the form to:

    Project Manager – Text

    Date Received – Date picker

    Due Date – Date Picker

    Comments – Multiple Lines

    I tried typing the dates in the format of 2010-02-05 but it still doesn’t work.  I even tried changing the data source fields to use date picker but it doesnt show up on the form.

    Please be extremely detailed and tell me what I am doing wrong.  This is driving me nuts.  

  • PxPx says:

    Second question on the infopath form it shows all of the current projects in the project list I don’t want to do that I only want to show the fields for the user to submit a new project to a project list in SharePoint.  

  • HDMorgan says:

    I have followed the instructions in this post and I can connect to my Sharepoint List and see the info posted in Sharepoint via the InfoPath form but I get an error when I try to submit data from the InfoPath form back to the SharePoint List.

    Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.

    <detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/"&gt;‘Element’ is an invalid XmlNodeType. Line 4, position 10.</errorstring></detail>

    Any help would be greatly appreciated.

    Thanks

  • david.l.brandt@comcast.net says:

    Thank you Scott for the excellent post!

    I was able to successfully submit a new record to my list.  I would like to be able to edit and update existing list items as well.  I expect this will be a variation on the theme you established here, but I have not been able to muddle through to the solution.  Can you outline the process for me or point me to an appropriate post that will help me on my way?

    Your help is very much appreciated.  Thanks!

    David

  • infopath says:

    Hi David,

    Thanks…do perform and edits, deletes, etc. you will need to use code. Take a scan through the comments and you will find sample code on exactly how to do this.

    Scott

  • infopath says:

    HDMorgan,

    Are you using the initial process documented in this blog post or are you using code to perform the submit? If you are using the initial process then you will want to make sure you have mapped the "submit" options appropriately as documented in step #6. If you are using custom code to perform the submit, then you will need to debug your code by stepping through it to see where the code fails.

    Scott

  • stuckinoregon says:

    This tutorial worked great for laying the foundation. In our case, we have need to implement several dropdown boxes that will use another SP list for the data source and we also have some forms that will need to have checkboxes. Any suggestions for how to accomplish this without a ton of coding?

  • infopath says:

    In response to the last comment from username stuckinoregon:

    You can find out more about getting data from SharePoint lists into InfoPath 2007 forms on office.microsoft.com/…/HP100931601033.aspx.

    If you're using InfoPath 2010, check out the following blog posts for details on improvements that we've made to SharePoint list data connections in this release:

    blogs.msdn.com/…/sharepoint-list-data-connections-in-infopath-2010.aspx

  • Sam says:

    How do I add the data from the repeating section of a Infopath form to Sharepoint???? I want the repeating section to be treated as data by itself. Currently, the only way to view the data in that section is by opening the form which I dont want any help.

  • Shizuru says:

    Great article. Im new to CAML and wondering will it work on multiple lines of text? I have a list for agenda items and one of the column contains multiple lines, how would I write the CAML template?  Thanks

  • Scott Heim says:

    Hello everyone,

    Sorry for the delay in responding.

    stuckinoregon: you have a couple of options: use the alternate method explained in previous comments in this blog (this is where I show how to use other controls such as dropdown boxes, date picket, etc.) with the caveat of…this method will only work if you use the InfoPath client. If you need to use your form in the browser and still have these other controls, you will need to use code. (Again, in other comments on this blog there is sample code for this as well.) Lastly, as noted by the InfoPath team, there are many improvements to this process in 2010. 🙂

    Sam: My apologies but I am not sure if you are referring to submitting the InfoPath form to a library or to a list? Can you shed some more light on what you have designed so far?

    Shizuru: Basically teh same information as what I provided above for stuckinoregon. You can use the altermante method so you can set the text box to allow multiple lines of text, use code or…InfoPath/SharePoint 2010.

    Scott

  • Shizuru says:

    Hi Scott,

    Thanks for the suggestions.  I checked every comments posted and found the alternative method to submit combo boxes, rich text, etc. I got it to work too.

    Now, my next question is…is it possible to submit multiple entries (repeating table) all at once? My form contains repeating table but the 'submit' button only submits the 1st entry in the repeating table. I would like to submit all the entries in the SP list upon clicking the submit button.

    We are using IP2003/SP2003. I searched and read thru various similar blogs but I could not find anything I could use.  I can only use vbscript/jscript.  

    Would you happen to know any other alternatives??

    Thank you

  • Alphamax says:

    The example shown makes all the controls used to submit text fields.  How can I modify it so that I can use date contols, dropdowns etc to submit data?

  • slheim says:

    Hi Alphamax,

    Take a look through the comments – I have provided steps on how to modify the design to use other types of controls.

    NOTE: Without using code, the new design will only work with the InfoPath form opened in the rich client. If you need to use your form in the browser, you will have to add code for this new design to work and once again, there is sample code in the comments for this as well.

    Scott

  • Armaghan says:

    This method is very helpful for me, but I have one problem:I don't want to import the values mannualy, I just want to set column's value in the rule of submit button. But I have to set the "Field" parameter of xml data connection so all of columns return the same data.

  • slheim says:

    Hi Armaghan,

    If you are using InfoPath 2007 with Microsoft Office SharePoint Server 2007 then browse through the comments in this post – you will see alternate methods for entering the data. There is a way to do it as you ask but your form template must be a "client only" design – if it will be used in the browser, it will have to be code. Both options are in my various comments in this post.

    Now, if you are using InfoPath 2010 with SharePoint 2010 then you now have the ability to customize a list using InfoPath and that custom form design will then be used to add/edit your list items!

    Scott

  • Greg says:

    It all works fine when I preview it from within InfoPath 2007.  It successfully adds the new item to the list and no errors occur.

    However, when I publish the form to SharePoint, open the form from there (browser based), and try having it add a new item, a dialog box pops up saying "An error occurred while the form was being submitted".

    I've started from scratch twice now and carefully followed the instructions each time.  What setting am I missing that would cause it to fully work while in preview mode, but fail with this error when running it from the SharePoint library within the browser only?

    Thanks in advance for any suggestions.

  • Scott Heim says:

    Hi Greg,

    Here is the best way to troubleshoot this:

    You should eventually see an error regarding that data connection. Hopefully this will point you in the right diagnostic direction. 🙂

    Scott

  • Ben Janssen says:

    Is this solution compatible with infopath browser forms?

  • Scott Heim says:

    Hi Ben,

    If you are referring to the steps as documented in the original post, then yes. If you look through the numerous comments in this post you will see other methods for implementing this and depending on which method you choose will depend on whether that solution will be compatible with the browser.

    Scott

  • Ren says:

    Why is this dated 2007 and titled Info Path 2010?!?!

  • HR says:

    Hi Scott,

    This is great post but how do you call/Invoke this InfoPath form from SharePoint List –> New –> Item?

  • Scott Heim says:

    Hi HR,

    If you are using InfoPath 2010 with SharePoint 2010, then this post would no longer apply as you can simply use InfoPath to customize your SharePoint list form. However, if you are still using the 2007 versions then you would need to provide a link (say on your main landing page) that would simply invoke this form. I am not a SharePoint expert but I don't know of any way to customize the New | Item link to point to this form. So instead of having your users go to the list, simply provide a link to the published XSN.

    Scott

  • Michael says:

    Actually, this method here is great for 2010.  You can use the steps outlined here (with a few tweaks) to alter the default form on top of a list in order to bring in the data from a 2nd list (probably linked to the first) and make it read/write as well rather than just read only.  Very very handy.  

  • Michael says:

    Actually, this method here is great for 2010.  You can use the steps outlined here (with a few tweaks) to alter the default form on top of a list in order to bring in the data from a 2nd list (probably linked to the first) and make it read/write as well rather than just read only.  Very very handy.  

  • Faraz says:

    Scott,

    Thank you for the wonderful tutorial you have posted! It helped to understand a lot about info path that I didn't know about. I've followed your instructions to the bone and everything worked out pretty well.

    But I am experiencing another issue that isn't addressed in the comments — I've read through all 22 pages of the comments and can't seem to find anything :

    When I submit the form, the sharepoint list gets appended (which is great) — but the issue is that the record is entirely blank! All of the fields are literally blank. I checked the GUID, double checked and triple checked the field names from the manifest source file, and the CAML template for my fields. In a last ditch effort, I also changed all the column types to string (thinking it was a data type issue, but it wasn't). No matter what, the new records are always blank.

    The weirdest part is this: when I design a form using a repeating table to list out the field names, it works fine (the new record has the information I type into the form).

    But when I manually create the text fields (and name them accordingly), and use the form that way, it submits blank fields. For reference, my field names are all in CAPS and have no spaces (it shouldn't be a naming issue, I think)

    I am at a total loss and would appreciate your advice/help on how to address this issue.

    Thanks,

    Faraz

  • Scott Heim says:

    Hi Faraz,

    Wow – I can honestly say I have never seen that behavior. 🙂  So if all the fields are blank, how do you know an item is getting added to the list? (Just out of curiosity <g>)

    So – if you have gone through things like this:

    And if you truly see a new row in the list then the above are probably ok, then I honestly am not sure what could be causing this. The best option may be to open a support case so we can take some time and dig into this with trace files, etc.

    I wish I had a better answer but I cannot even reproduce this to try and determine what is going wrong. 🙂

    Scott

  • Faraz says:

    Scott,

    I managed to figure out what went wrong. I had to follow instructions to modify the Manifest file in the infopath form… for reference, I followed the directions on the following website, that told me to apply some rules to Sync the Main fields with the XML fields of the Batch node…

    algahtani.net/…/tracking-infopath-forms-using-sharepoint-lists

    I also had to re modify the manifest file according to this website:

    http://www.infopathdev.com/…/55159.aspx

    As you can see, the tags that looked like this, "…/Batch/Method/Field", in the manifest file (under the rules section) needed to be modified to "…/Batch/Method/Field[@Name='FieldNameOnInfoPathForm']". Once I did these two, the form was no longer inserting blank records.

    If you could modify your instructions to include this situation, or at least reference to the said websites, it would help a lot of people out. If not, hopefully they read my comment and have something to work with.

    Once again, thanks for the advice!

    Faraz

  • Scott Heim says:

    Hi Faraz,

    I am glad you were able to isolate the problem! For note, I do believe I have this documented on page 15 of the blog in my 9 Jan 2009 10:10 AM comments for another user.

    The original post was not designed to be setup this way so these steps did not come along until later.

    Scott

  • Devubha says:

    Great Article,

    But I am facing an issue,

    I am not able to change the Created By field.

    As using this technique all the data is inserted from System Accout.

    I want to change the Creatd By from the Code.

    Is this possible. Please reply asap. Thanks

  • Scott Heim says:

    Hi Devubha,

    It is my understanding that the only way to modify the "created by" and "modified by" columns is to use the SharePoint object model, which would mean code that needs to run on the server and not the client. You could do this with code behind InfoPath if your form was only running in the browser or you could create a custom web service and have your InfoPath form submit the list data to the web service and then have the web service code add the item to the list and subsequently update the created/modified by fields.

    Scott

  • Pissed Off says:

    Will someone either:

    a) remove "Infopath 2010" from the top of this blog

    b) remove all InfoPath 2007 articles from this blog

    I'm sick of trying to search for InfoPath 2010 documentation and continually finding 2007 info.

  • Lovekush Kumar says:

    Thanks Scott/Matt for such a wonderful information..

    I followed the steps mentioned by you and its working fine but i have to submit the mutliple items(add more items) to the Custom List. Is it possible through the approach mentioned above(no code).

    Thanks in advance.

  • Scott Heim says:

    Hi Lovekush Kumar,

    If you need to submit multiple items (i.e. multiple rows of data) then the only way to do this is with code as you would need to loop through all your rows and add each one to this list. The only way to enumerate multiple rows of data in an InfoPath form is via code.

    Scott

  • MAK says:

    Hi,

    I am trying to populate all Sharepoint lists in a Infopath ListBox Control using List Webservice with Getlist method. But it is getter Alert message , when i click the "Next" after select the Getlist Method.

    Message: Infopath was unable to create a schema from the results of the web service call

    Please guide me , how to populate all listnames in the listbox control.

    Thanks in Advance

    MAK…!

  • Eduardo Padilla says:

    Please I need help, I sent this message in InfoPath 2007:

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

    <detail><errorstring xmlns="schemas.microsoft.com/…/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring></detail>

  • Scott Heim says:

    Hi Eduardo,

    I would suggest enabling Verbose logging on your SharePoint site (for all categories), reproduce the error and then check the ULS logs.

    What happens if you follow the exact steps in this post (and by exact I mean the same names, etc.)?

    Scott

  • Sam Carlson says:

    Hi Scott,

    I think this may be what I'm looking for, but perhaps I can explain and you could tell me if there is an easier approach.

    I have InfoPath 2010 form displaying a SharePoint 2010 list item. There is a secondary data connection displaying a related SharePoint list via a repeating table. I want to add a new item to the secondary data connection.

    Do I need a Submit data connection to a Web service? or is there a more direct approach?

    Thanks,

    Sam

  • Scott Heim says:

    Hi Sam,

    There is no way from the UI to "submit" data to a secondary data connection as it is a "Receive" connection. You would need to have a separate connection (web service would be best) that takes the data and submits it to the data store that backs up that secondary connection.

    Scott

  • Dave says:

    tutorial was very easy to follow, thanks.  how can I incorporate combo boxes or radio button selections?

  • Scott Heim says:

    Hi Dave,

    I know there are a lot of comments on this post but if you wade your way through them you will see some alternate design options so you can use other types of controls. Now depending on how you go about this some of the design options will only work if the form is used in the InfoPath client but I have noted that in my comments where I have documented the design changes.

    Scott

  • chintan says:

    Hi Scott,

    very nice article on this issue.

    However, I did all this steps but getting below error when clicking on submit button (in preview)

    "InfoPath cannot submit the form.

    An error occurred while the form was being submitted. "

    I checked GUID value twice, but it failed.

    Pls advice where i got wrong.

  • Chintan says:

    Hi Scott,

    I did all of your steps, but when i submitted (in Preview mode), I got msg box

    "InfoPath cannot submit the form.

    Some rules were not applied."

    Details:

    "InfoPath cannot submit the form.

    An error occurred while the form was being submitted"

    I checked GUID twice. It is correct. My webservice URL:

    http://servername:port/_vti_bin/lists.asmx

    Pls let me know where i have gone wrong.

  • Some corretion in this forum says:

    Hi Scott,

    I read your useful post. I did all steps, but somehow my form was not submitted while clicking on submit button. But, finally i found solution

    Solution/Correction:

    Scott's Webserive URL: http://servername/_vti_bin/lists.asmx

    My Corretion: http://servername/sites/SiteColletionName/_vti_bin/lists.asmx

    After updating this URL I was able to submit the form

  • eric says:

    Hi Scott,

    Thanks for the great article.  I have a question.  

    If I want only to update a single instance from the list, what do I do?  Let's say, I have a custom list with some custom columns.  Under that I have multiple instances.  

    I'll get the single specific instance value to InfoPath(No problem here), then I want the value of one column from the specific instance to be changed/updated.  Could you tell me How to do that?

    Thanks.

  • Scott Heim says:

    Hi Eric,

    How would you like to do this? Code or no code?

    Scott

  • Patrick says:

    Hi,

    sorry for my bad english.

    I would like to change some fields after I have created them.

    For example:

    I created:

    Test

    Scott

    Heim

    someone@hotmail.com

    555-1212

    now I would change the email in somebody@hotmail.com after i created the listitem.

    I will only update the emailfield. I dont want to delete this and create a new one.

    Is that possible in the form? I can change the emailaddress. But if I click on submit the emailaddress is the same as befor. It is someone@hotmail.com an not somebody@hotmail.com.

    best regards

    patrick

  • Scott Heim says:

    Hi Patrick,

    If you look through all the comments in this blog, you will find sample code to do exactly what you want…in addition, the sample I had provided also allows for deleting an item from the list as well as editing an existing item.

    However, if you are trying to do this without code it will be more challenging. You have to know what the SharePoint ID is for the list item you want to update and then in the "Add List Item Template" XML file you would need to change the Cmd attribute from "New" to "Update". So in essence, to do this without code you would need to have 2 of those Resource files (i.e. "Add List Item Template" and "Update List Item Template") and then if you want to update an existing item, make sure you populate the item "ID" column in the "Update List Item Template" file and then execute that connection.

    Scott

  • Patrick says:

    Hi Scott,

    nice to hear from you so soon.

    I created a second xml:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="Update">

           <Field Name='Title'></Field>

           <Field Name="FirstName"></Field>

           <Field Name="LastName"></Field>

           <Field Name="Email"></Field>

           <Field Name="Phone"></Field>

    &lt;Field Name=&quot;Test&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Ampel&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;ID&quot;&gt;&lt;/Field&gt;
    

       </Method>

    </Batch>

    I named it: updateitem.xml

    and added the above xml to a new dataconnection.

    dataconnection -> receive -> xml -> updateitem.xml

    But what is the next step?

    Sorry, I´m still a newbie in InfoPath…

    Patrick

  • Scott Heim says:

    Hi Patrick,

    So assuming you created a sample as per the steps I have in the initial post of this blog, you would simply launch your InfoPath form and fill in all the fields in the table, including the one you want to update and the SharePoint ID for the item you want to update. When you submit the form to the web service, it should then update that one item. So a couple of key points:

    Scott

  • calvaradog says:

    Hi,

    Can I submit data to sharepoint list with lookup fields?

  • Scott Heim says:

    Hi calvaradog,

    Yes – you just need to be sure to submit the correct "data" – what I mean by this is the following: if you are using a lookup field, it may be storing the "numeric" value of the option (i.e. 1 – Red, 2 – Blue, etc.) so you would need to submit the numeric value for the selected item if this is the case.

    Scott

  • Richell Grant says:

    Ok, I have noticed that not all of the screen shots are actually current with InfoPath 2010, but I am working my way through this.

    However at step 6 is where I am a bit confused. How or where do I get the list.asmx? Is it already created? Did I created it? I have been getting messages that say "InfoPath cannot find or cannot access the specified Web Service Description: not a valid xml file; not a valid xml document; DTD is prohibited; Line 2, Position 9"

    I am new and still learning InfoPath and dont even know how to get to the HTML code. When I view Code Editor it shows some VB, but not much.

    How do I correct this issue? (The error message)

    Thank You

  • Scott Heim says:

    Hi Richell,

    The URL to the "lists.asmx" web service will depend on where your list resides. Here are some examples:

    http://server/_vti_bin/lists.asmx

    http://server/site/_vti_bin/lists.asmx

    It is very important that you get the web service URL correct. The easiest way to insure this is:

    Scott

  • Latte says:

    Hi,

    Great post, worked for me first time.

    If I want to use this on an already existing list with dropdown boxes, content types and so how will I proceed?

    I want the already existing list to feed some information into my fields using dropdowns and also is there nothing I can do about the form design? Do I absulutely have to use a 2 column table or can I design the form myself and somehow map the fields on the form to infopath?

    Thanks.

  • Scott Heim says:

    Hi Latte,

    If you scan through all the comments you will get to a section where I have provided complete steps on how to change the form design.

    Scott

  • Jake says:

    Ok, I've used this method to submit an InfoPath 2007 form to a SharePoint 2007 list. I followed the steps posted by Brynnie5209 to modify the form so I can utilize InfoPath controls like dropdown box, checkboxes, etc. All works exactly as described. My only problem is I can't get the form to open in a browser, only the InfoPath client. I'm getting an "undefined namespace or unsupported function" error in the Design Checker that refers to the "Add List Item Template.xml" CAML document. Is there any fix to this that will enable me to open the form in a browser? Thanks.

  • Scott Heim says:

    Hi Jake,

    There should be no reason why this sample would not work in the browser as I do this without issue. If the error refers to something in the Add List Item Template.xml file, can you please copy/paste the contents of that file so I can see if anything seems odd?

    Thanks,

    Scott

  • Dhaval says:

    I followed this article but when I click on the Submit button I get the following error.

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

    <detail><errorstring xmlns="schemas.microsoft.com/…/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring></detail>

    I am not sure which file the System can not find … Any idea ?

  • Claudia says:

    How update list items? I's used this solution but I can´t update.

    Also, I'm used CAML command but doesn't work.

  • Scott Heim says:

    Hi Claudia,

    If you look through all the comments for this blog you will see I have previously provided sample code to perform additions, edits (updates) and deletes.

    Scott

  • Scott Heim says:

    Hi Dhaval,

    I really am not sure what file it is looking for – I know if you follow the initial steps in this post as they are documented, it works so it sounds like something may have been missed.

    Scott

  • Confused says:

    Hi Scott,

    I'm getting the same error message as Dhaval.  Any thoughts yet on what's I might be doing wrong?  The only spots in your directions where I felt somewhat unsure were in step 6.  First, when did we add an “Add list Item Parameter” data source? Should that just show up automatically? Mine is called "Add List Item Template"…  Was I supposed to change that somewhere? Second, I'm not sure I'm putting the right thing before /_vti_bin/lists.asmx.  How much of the sharepoint list address should I be including as part of the servername?

    Okay, thanks very much for your help!

    Confused :-/

  • Scott Heim says:

    Hi "Confused" 🙂

    If I have text that the XML file was to be called "Add List Item Parameter" then that was incorrect and it should be "Add List Item Template.xml". Now when you add that file as a "Receive" data connection it will automatically appear in the Resource file list but without the extension (i.e. Add List Item Template).

    In regard to the URL for the correct "lists.asmx" web service, you need to use the SAME base URL as where your list was created. So let's assume you created your list at the root site collection so the URL would look like this: http://yourserver/lists/yourlistname – if this is the case, then the URL for the web service would be: http://yourserver/_vti_bin/lists.asmx. However, if your list is at a subsite like this: http://yourserver/yoursite/lists/yourlistname then the URL for the web service would be: http://yourserver/yoursite/_vti_bin/lists.asmx

    Does that help?

    Scott

  • Confused says:

    Hey Scott,

    Thanks so much for the response, works like a charm!!

    You rule.  Seriously.  Awesomeness.

    🙂

  • Confused says:

    Hey,

    Sorry to bother you again, but I am totally stuck… I've been going through the comments (to no avail) trying to figure out how to set this up to handle drop downs, radio buttons, yes/no boxes, and other stuff, beyond simple text boxes. Any suggestions as to websites, tutorials, anything(please!) that might help?  I'm at a loss 🙁

    Thanks!

  • Scott Heim says:

    Hi Confused,

    No problem :). The best solution will be to find the steps I have previously provided in these comments. There are complete steps on how to modify the design of your XSN to use other controls. Note that if you are developing a browser form, you will need to use code. There is sample code in the comments as well.

    Scott

  • Confused says:

    Okay, so I really have no clue what I'm doing here.  I don't think I'm developing a browser form, but I'm not sure… All the users have infopath installed on their computers, so maybe I'm not? I have read every single comment on this site and other than the sample code (which I have no idea how to use), I still don't understand how to change the form.  Is there a book or something you can recommend?  The comments/answers seem to be a little too advanced for me. 🙁

    Thanks

  • Scott Heim says:

    Hi Confused,

    I don't know of any books, sites, etc. that would explain this any clearer than what I have done in the post comments. If you are truly unfamiliar with InfoPath then these steps will be challenging. There is training on InfoPath (office.microsoft.com/…/HA102227501033.aspx) and this will probably be of use for you to get a handle on InfoPath but there is nothing in there specifically to this post.

    Scott

  • Confused says:

    Are all the changes I'm going to make going to happen in the manifest.xsf file? Will I need to make more than one xml template for each type of control and/or section I want to add? Thanks again

  • Confused says:

    Just kidding, all fixed, thank you!!!!!!

  • Confused says:

    I'm back.  I'm trying to make a version of my form for query/update purposes.  I saw your post about this ("public void ctrl26_5_clicked…").  Do I just copy and paste this stuff into the manifest file, replacing the field names with my own?

    Thanks!

  • Rod Need your Help!! Please says:

    Hi Scott, I am confused starting at step #3

    1. Add a “Receive” type secondary data connection to the Add List Item Template.xml file created in Step #2. My reply Done

    (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.)My reply Done

    1. 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.  My reply Not sure I follow you on how I should add the data connection.

    So of course when i get to step 5 Step 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

    My reply its not there What am I doing wrong?

  • Scott Heim says:

    Hi Rod,

    Not sure I follow the confusion…you are simply adding a "Receive" data connection to the SharePoint list called MyContacts…assuming you named it MyContacts. So whatever your sample list is called, simply add a data connection to that list.

    Scott

  • Rod Need your Help!! Please says:

    Scott,

    Thanks for replying. I am trying to following the instructions as written above. When I get to Step 5 there is no MyContacts data connection in my drop menu. Reading step two is a bit confusing as I am not sure exactly what i am doing.

    1. Create a new, blank, browser-compatible form template I can do that
    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.)I did that by adding the field to the CAML Template.XML file was this wrong?

    3. Add a “Receive” type secondary data connection to the “MyContacts” SharePoint List created in Step #1 When i do this am I supposed to use the CAML template to create this data connection? Not clear to me

    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.

  • Scott, are you there? I really need your assistance, I have looked at serveral instructions and your appears to be the most accurate. I signed in as my name is Big Rodney W My comments are under Rod Need your Help!! Please title

  • Scott Heim says:

    Rodney – I don't mean to be a wise guy with this statement but if you are having trouble adding a data connection, getting this post to work for you could be problematic.

    At any rate:

    You may want to take a look at this information before going any further with this post:

    InfoPath 2007 Training Labs

    office.microsoft.com/…/HA102227501033.aspx

    InfoPath 2010 Training Labs

    msdn.microsoft.com/…/gg180739.aspx

    Adding data connections and using them as sources for your controls is basic InfoPath functionality. You need to be comfortable with the basics before digging into something like this.

    Scott

  • Question says:

    Hi Scott,

    I've successfully set this up, but have one question:  Are submissions made via this method anonymous?  I'd like to set up a "survey" type form, but it's really important for the users that the resulting records aren't traceable to the submitter.  (I know there's a survey feature built into SP, but it's not truly anonymous, so it won't work for my purposes.) Using your method, I can't find anything pointing to who's submitted what (there's no "modified by" column), but I wanted to double check with you because – well – you're the expert.

    Thanks!

  • Scott Heim says:

    Hi "Question" 🙂

    It sounds like you may not have the "Created By" and "Modified By" columns showing in your list? This sample should not be submitting anonymously – now I am not a SharePoint expert but I know you cannot "submit" an InfoPath form directly to a "library" anonymously; however, I have not tried this with a list. My suspicion though is the user that submitted the list item will appear in the Created By and/or Modified By fields.

    Scott

  • Question says:

    Yeah, you're totally right, my mistake.  So as far as you know, there's no way to override the automatic Author and Editor fields? Frustrating. Thanks for your answer, though.  I appreciate it.

  • Scott Heim says:

    Hi "Question" – the only way I would know to do what you need would be submit to a custom web service that takes the data from the XML file and adds it to the list. Then all entries would come in under the same account…whatever the identity account is for the web application.

    Short of writing a custom web service for this, I don't know of a way to submit to a list anonymously. You may want to ping a SharePoint forum on this for ideas as I am not a SharePoint expert.

    Scott

  • Tricia Trinh says:

    I am new to InfoPath and SharePoint. I have been trying to submit data from InfoPath 2003 (***) to SharePoint list.

    1. My list GUID is in format {95EF64EA-0FC0-45F3-B00A-212CF8AEFEA6}
    2. My CAML is:

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

    <Batch OnError="Continue" ListVersion="1" ViewName="{79FFC957-EE73-4653-868D-34D4CA6DC75}">

       <Method ID="1" Cmd="New">

           <Field Name='Title'></Field>

           <Field Name="ProgramName"></Field>

           <Field Name="PGM"></Field>

           <Field Name="PMT1"></Field>

           <Field Name="PMT2"></Field>

           <Field Name="PMT3"></Field>

           <Field Name="PMT4"></Field>

           <Field Name="PMT5"></Field>

           <Field Name="PMT6"></Field>

           <Field Name="PMT7"></Field>

           <Field Name="PDQOS"></Field>

           <Field Name="Platform"></Field>

           <Field Name="Folder"></Field>

           <Field Name="MS"></Field>

       </Method>

    </Batch>

    !!! Do I need to add <Field Name="ID"></Field> to my CALM file !!!

    1. I added a "Receive" type secondary data connection to my CAML
  • I added a data source (receive) to the sharepoint list required.

  • I added a "Submit" type of web service data connection to the "lists.asmx" web services

  • (http://servername/sites/mysite/_vti_bin/lists.asmx); with the "UpdateListItems" method;

    Provide my list GUID to "listname" parameter; and select my CAML data source to "updates" parameter ("BATCH" and

    "XML subtree, including selected element")

    It is a simple form that just wants to submit to the list.

    When I preview the form – I can enter the values and submit. I then get NO response (No Error) but the new item was not

    added to the SharePoint list.

    Any Help is greatly appreciated.

    (***) I create the InfoPath 2003 form from InfoPath 2010 (using compatibable option). is there any differences from

    the sample that I should aware to correct my issue?

    my email is haichautrinh@yahoo.com

    Thanks

    Reply
  • Scott Heim says:

    Hi Tricia,

    I know there are a lot of commments on this post but if you read through them, the behavior you are experiencing is addressed throughout this post. In short, there are a number of "failure" points where you can see this behavior:

    1) Make sure you are using the correct URL for the "lists.asmx" web service. For instance, if you list is located off the root like this: http://server/Lists/ListName then the submit URL would be like this: http://server/_vti_bin/Lists.asmx. However, if your list resides in a subsite like this: http://server/site/Lists/ListName then the web service URL would be like this: http://server/site/_vti_bin/Lists.asmx

    2) Make sure your "Add List Item Template" XML file contains the actual "SharePoint" column name. For instance, say you create a column in your list named: My Column but afterwards realize you don't want it to have a space. If you go back to your list and rename it without the space, the underlying SharePoint column name will still have the space and it will be encoded like this: My_x0020_Column. It is this name that needs to be in your Add List Item Template XML file. Here are the easiest steps to determine the actual SharePoint column names for your columns:

    <xsf:field internalName="Title" required="yes" type="Text"></xsf:field>

    3) Once you have completed the above steps, if the update still does not work then I would suggest (make a copy of your Add List Item Template XML file) removing all but one of the fields you have in this file and see if you can get that one field to update correctly. If so, then continue to add them back until you find the one(s) that cause the process to no longer work. For instance, if any of your columns are a Date and Time column, then you have to have the value entered in a specific format.

    Hopefully some of this helps! The information above (along with other suggestions) are throughout this blog.

    Scott

  • Darren Weiss says:

    I am getting this error message and cannot figure out how to fix it i followed all the directions above.

    Darren Weiss

    dweiss@nybloodcenter.com

    InfoPath cannot submit the form.

    Some rules were not applied.

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

    <detail><errorstring xmlns="schemas.microsoft.com/…/">

       List does not exist.

       The page you selected contains a list that does not exist.  It may have been deleted by another user.

       </errorstring><errorcode xmlns="schemas.microsoft.com/…/errorcod

  • Scott Heim says:

    Hi Darren,

    The first thing to check is that the URL to the "lists" web service is at the same "level" as your list. For instance, if your list is here:

    http://server/lists/YourList

    Then the web service URL for the lists web service would be:

    http://server/_vti_bin/lists.asmx

    However, if your list is on a lower subsite like this:

    http://server/site/lists/YourList

    Then the web service URL for the lists web service would be:

    http://server/site/_vti_bin/lists.asmx

    I would start by double-checking you have the correct "lists" web service URL. If it does not point to the same "level" (site) as where your list lives then you will get an error that the list cannot be found.

    Scott

  • Heerachand says:

    Hi Scott,

    How will I save my infopath in offline mode. My req is that I need to fill the infopath as many times as I can when I am in offline mode, save it as xml and then submit them to the sharepoint.

  • Scott Heim says:

    Hi Heerachand,

    You will need code for this but it is really no different than any other offline InfoPath form. Your code will need to:

    Scott

  • Matt says:

    Hi Scott, I've adapted the steps above to update rows in a sharepoint list instead of adding new rows, and it works fine. However, I don't want users to actually see the repeating rows of data, I would rather set them 'behind the scenes.' In my rules I have tried to set the repeating fields, but so far it's updating all the 'field' rows in the repeating table to the same value even though I set my rule to update based on the @name.

    This is what I have in two separate rules:

    Set Field to 1 where @Name=ID

    Set Field to Reserved where @Name=Status

    This is what I get back:

    ID=Reserved

    Status=Reserved

    Any suggestions would be greatly appreciated.

  • Scott Heim says:

    Hi Matt,

    I know its a lot of comments on this post but if you look through them you will see that you need to use code. Rules cannot be used to set data in a repeating structure. At various points in the past, I have provided sample code for this process.

    Thanks,

    Scott

  • Stacey says:

    I am hitting two issues with this tutorial. The first is if I have the following CAML:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

    &lt;FieldRef Name=&quot;LinkTitle&quot;/&gt;
    

       </Method>

    </Batch>

    The form will successfully write to the list, but it wont record the title that i provided. Instead, when navigating to the sharepoint list it says "(no title)".

    If I update the CAML to be <FieldRef Name="Title"/> I get the following error:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

    <detail><errorstring xmlns="schemas.microsoft.com/…/">Cannot access a closed Stream.</errorstring></detail>

    I also get this error if I add any fields other than the LinkTitle one.

  • Scott Heim says:

    Hi Stacey,

    I am not sure I follow exactly what field you are trying to set – so let me describe what I just tested:

    If I am not following correctly, please accept my apologies.

    Scott

  • Stacey says:

    Hi Scott,

    Sorry for my delay. I was able to solve my issue (though I've hit a few others.) Basically, I had copied the field references from the code view of a sharepoint list view.. which gave me:

    <FieldRef Name="Title"/>

    Instead of:

    <Field Name="Title"/>

    (And boy do I feel silly!)

    I am stuck once again and having trouble finding resources online and have read over the comments on your blog. First let me provide some background information on what I am trying to do.

    I have two custom sharepoint lists – Event Details and Schedule. This is a 1 to many relationship, meaning 1 event to many schedule items. I want to be able to create and edit items for both lists in a single form.

    With that said, I am using Infopath & Sharepoint 2010, would prefer to keep it as a browser form and will not be able to use custom code.

    Do you have any good resources for me? I am able to get the new item code to work, but I need to also have update, delete and filter capabilities.

    Thanks in advance!

    Stacey

  • Scott Heim says:

    Hi Stacey,

    Glad you were able to get this working! So in regard to your follow-up questions…this is going to be a bit challenging…especially if you cannot use code. What you are going to have to do is implement a way to set the "Cmd" attribute in the list template XML file to the appropriate command (i.e. New for adding items, Update for editing items and Delete for deleting list items.) In addition, you will need an XML file for each list you are updating. So your button will need to update the appropriate XML file and then not only update the fields (nodes in the XML file) but also set the appopriate "Cmd" attribute as well.

    So the way that I would implement this would be as follows:

    A few additional comments:

  • If you allow a deletion of a parent item, you will probably need to implement logic to delete the corresponding child items as well.

  • I have not tested this scenario myself so off the top of my head I don't know of any other "gotchas." 🙂

    Scott

    Reply
  • Stacey says:

    THanks for the information Scott! Do you know of a way to set the ID in the CAML dynamically? How I'm envisioning this form is having the receive repeating table with a button that says "delete" and another that says "Update" so that you can modify each row. How do I send the ID to the CAML?

    Also, do you have any information around filtering the receive connection? I see query fields, and from reading over the InfoPath blog it sounds like you can use those fields to filter.. but I can't seem to figure out how.

    Thanks!

    Stacey

  • Scott Heim says:

    Hi Stacey,

    Sure – when you add a column to the repeating table to store the buttons, you get a button on each row. As such, when you click the button to set the CAML fields, the values come from the fields on the same row as the button. You will just need to include the ID column from your list.

    Now the issue you are going to run into is this: how do you actually set the appropriate fields in the CAML file from a button…and this is where it gets tricky. If you read through all the comments in this post you will see I have documented a couple of options for this:

    1) Hand-modify the manifest so you can specify through a subscript value which node gets which value.

    2) Use code behind the XSN to set the nodes in the CAML file

    So the problem with option #1 is this: that method will only work in an InfoPath client form. It is not supported for the browser. The issue with option #2 is that you now are adding code to your form template. This method will work for client or browser but you are adding code.

    Now, if you are using InfoPath 2010 and SharePoint 2010, then in many cases you can still publish your XSN directly to a library even with code! The caveats for this are: the "Microsoft SharePoint Foundation Sandboxed Code Service" must be running and the code that you are executing cannot access anything outside of the site collection. In this case, the code is just manipulating data with the XSN so the only other issue would be if the Microsoft SharePoint Foundation Sandboxed Code Service is running in your farm.

    Within the comments in this post I have provided a complete code sample for adding, updating and deleting list items so with the new Microsoft SharePoint Foundation Sandboxed Code Service feature of SharePoint 2010 this should be a viable option.

    I hope this helps!

    Scott

  • Charlie S. says:

    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?

  • garni says:

    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

  • Scott Heim says:

    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.

    Scott

  • Troels says:

    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,

    Br

    Troels

  • Scott Heim says:

    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.

    Scott

  • Troels says:

    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 🙁

    BR

    Troels

  • 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.

  • Scott Heim says:

    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.

    Scott

  • EZ E says:

    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.

    Thanks

  • Scott Heim says:

    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 note…one 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.

    Scott

  • Troels says:

    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

  • Scott Heim says:

    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".

    Scott

  • Troels says:

    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

    Troels

  • Scott Heim says:

    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.

    Scott

  • Troels says:

    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

    Troels

  • Scott Heim says:

    Hi Troels,

    Sounds like you may have missed something? The code still populates the "Add list item template" XML file and executes the "Web Service Submit" data connection. It is this connection that is tied to your list. Assuming you have this setup, make sure of the following:

    http://server/subsite/Lists/ListName

    Then the web service URL would be like this:

    http://server/subsite/_vti_bin/lists.asmx

    However, if your list is at the root level like this:

    http://server/Lists/ListName

    Then the web service URL would look like this:

    http://server/_vti_bin/lists.asmx

    There are a number of other issues that can cause data to not be sent to the list. Browse through all the comments and you will see a number of troubleshooting steps for these issues.

    Scott

  • re says:

    <a href="http://www.aengiascacascscaerinccascasgcaguideksdfjls.tv">age of empires guide</a>

  • Justin says:

    I got all the way to step 5 with InfoPath 2010 (somehow this 2007 link showed up for me at

    blogs.msdn.com/…/default.aspx) and was thrown for a loop, because I couldn't figure out how to "Open the Data Source Task Pane". Rather frustrating.

  • Chulbul Pandey says:

    I am very new to Sharepoint/Infopath. I have followed this post step by step. I have published the form to a Form Library. On click of new I can see the existing items. But on click of "Submit" I get an error message saying "An error occurred while form was being submitted". Please help me with this.

  • Chulbul Pandey says:

    I made a mistake in the Webservice selection for lists. Now I am able to submit and I also See the success message – but item is not being inserted in the List. Please help.

  • Shemsedin says:

    nice article!!!!

    http://www.oxwebs.com

  • Dave says:

    Does this work with browser-compatible forms? I performed the steps documented and verified them several times.  When I click the Submit button, I receive no error message, yet the new item is not added to the SharePoint list.

  • Hi Dave,

    Yes – this works with browser forms. If you are using InfoPath and SharePoint 2007, go through the comments in this blog. I know there are a lot of them but many folks had the same experience and there are a number of reasons this can happen.

    If you have migrated to InfoPath 2010 and SharePoint 2010, then you no longer need to use this method. You can simply "customize" your list with InfoPath (this is an option on the Ribbon in the list), modify the form as you need and publish it back. Now, all the forms for the list will be your InfoPath form.

    Scott

  • Scott Heim says:

    Hi Chulbul,

    Browse through the comments in this blog – there are a number of reasons why the items would not be added to the list and all of these are covered at various points in the comments.

    Scott

  • BOM says:

    Sorry, I have a silly question here… the screenshots in Step 6, is that done in SharePoint Designer or Infopath 2010?

    Thanks

  • Scott Heim says:

    Hi BOM,

    InfoPath – and I believe, the 2007 version.

    Scott

  • BOM says:

    Hi Scott,

    Thanks for answering my question.

    I did all the steps in here and it worked well. Now I need to tweek some of the steps here for my own objective.

    1. Lets say i have more than 4 fields in the info form of different kinds – dropdown menus and check boxes. How do I edit the CAML code in Step 2?  
    2. How can I put controls on the repeating table that's submitting data to the SharePoint list? In this example, all fields in the table are text fields. Can I make some of them drop down menus and checkboxes?

    3. Lastly, I only need to submit data to a sharepoint list. I dont want the data in my Shapoint list to get populated in the infopath. Can this be done?

    Any advise will be appreciated.

    Thanks again.

  • Scott Heim says:

    Hi BOM,

    I know there are a lot of comments to this post but if you look through them, I provide complete steps for how to use other types of controls. I would encourage you to read through as much as possible on the other design options because depending on the design you choose, it may only work in the InfoPath application (versus a browser form.)

    Scott

  • Gennady says:

    Hello, Scott,

    tried thrice from scratch, read all comments.

    But on clicking Submit button I am getting:

      InfoPath cannot submit the form.

      An error occurred while the form was being submitted.

      The SOAP response indicates that an error occurred on the server:

      Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

      <detail>

           <errorstring xmlns="schemas.microsoft.com/…/">Element <Batch> of parameter updates is missing or invalid.

           </errorstring>

    </detail>

    I use Sharepoint Online, Plan E3

  • Gennady says:

    I resolved the problem of my previous comment "Element <Batch> of parameter updates is missing or invalid"  

    In Step 6.7, in Data Connaction Wizard  for "tns:updates" I should have chosen in "Include:" drop-down list the value: "XML, subtree, including selected element"  

  • Essined says:

    Hi Scott,

    Just to check if I saw this correctly. In Step 6-4."Double-click the “updates” parameter, select the “Add list Item Parameter” data source, select “Batch” and click OK" – Do you mean Add list Item Template?

    I don't think I created a data connection with that name.

    furthermore, when I submit my form, items are actually being added to the SP list. The only problem is that it's blank. Title is '(no title)' and other columns are empty. Would you happen to know where I got it wrong?

    Thanks in advance!

  • Hi Essined,

    My apologies – yes, that should have been "Add List Item Template." But in short, you will use whatever connection you created for that XML file. In regard to why they are appearing blank – it sounds as if the values in your form are not being mapped back to the nodes in that XML file.

    Scott

  • Troels says:

    Her is the code I use

    {

               // Write your code here. This is line 35

                           XmlNamespaceManager ns = this.NamespaceManager;

               //Create a DataSource object for the Add List Item Template data source

               DataSource dsAddListItem = this.DataSources["RecieveCompanyArchiveBatch"];

               //Create an XPathNavigator object for that data source

               XPathNavigator xnAddListItem = dsAddListItem.CreateNavigator();

               //Create an XPathNavigator object for the main DOM

               XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

               //Create XPathNavigator objects for each of our fields in the main DOM

               XPathNavigator xnComName = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:ComName", ns);

               XPathNavigator xnComAddress = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:ComAddress", ns);

               XPathNavigator xnComPhone = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:ComPhone", ns);

               XPathNavigator xnComMail = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:ComMail", ns);

               XPathNavigator xnTitle = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:Title", ns);

               XPathNavigator xnPersonName = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:PersonName", ns);

               XPathNavigator xnPersonPhone = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:PersonPhone", ns);

               XPathNavigator xnPersonMail = xnDoc.SelectSingleNode("/my:myFields/my:Group1/my:PersonMail", ns);

               //Set the values of each field in the companyXML data source to the values from the main DOM

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[1]",ns).SetValue(xnComName.Value) ;

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[2]",ns).SetValue(xnComAddress.InnerXml);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[3]",ns).SetValue(xnComPhone.Value);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[4]",ns).SetValue(xnComMail.Value);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[5]", ns).SetValue(xnTitle.Value);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[6]", ns).SetValue(xnPersonName.Value);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[7]", ns).SetValue(xnPersonPhone.Value);

               xnAddListItem.SelectSingleNode("/Batch/Method/Field[8]", ns).SetValue(xnPersonMail.Value);

               //Submit the data

               this.DataConnections["WebServiceSubmit"].Execute();

           }

  • Troels says:

    This comment is related to the code in the above comment.

    Hmm My first post dissipered my magic, so I will try again.

    When I try to submit I get the following error message:

    System.NullReferenceException

    Object reference not set to an instance of an object.

      at CustomerArchive_ver2.FormCode.CTRL17_5_Clicked(Object sender, ClickedEventArgs e)

      at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)

      at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    I have one section with 1 Rich textbox, 5 textboxes, and 2 comboboxes.

    The first combobox is populated from a sharepoint recieved connection(no  filter), and the second one with the first combobox as a filter.

    The sharepoint list names, are the excact same ones as in the form, and the xml fil( checked for spelling errors etc.).

    Where have I made an error???

    Troels

  • Scott Heim says:

    Hi Troels,

    Unfortunately there is no way of telling from just your code. You will need to run the form in "debug" mode so you can step through it and see what object is null.

    Scott

  • Ron says:

    Is it possible to update a list from an Infopath form that is submitted to a document library?  So you are adding data to the document library and to the lis.

  • Scott Heim says:

    Hi Ron,

    Sure – just add another "Submit" connection to your SharePoint library and then execute this connection along with the one to send the data to the list.

    Scott

  • Heerachand says:

    Hi Scott,

    I have tried the above steps and it worked correctly for me Thanks. However I need to submit customised form ( with 3 fields of single line of text, 2 drop down list values and two date field values) can you please help with the steps, I am new to infopath. Thanks.

  • Heerachand says:

    I mean instead of a repeating table with same field types , I need a form with 3 single line text fields, 2 with dropdown and 1 with date. Once user selects all these and fills the infopath form, this should be saved in the share point list on click of Submit button on the form. How do i achieve this.

  • Scott Heim says:

    Hi Heerachand,

    This has been covered a number of times in this blog. I know there are a lot of comments but take a look through them as you will find complete steps, sample code, etc. for doing exactly what you ask.

    Scott

  • Reeseburg says:

    I found the answer to the /Batch question…

  • Heerachand says:

    Hi Scott,

    I created the infopath form with drop downs and rich text boxes exactly like you mentioned in Page 13. Howevr there are some errors. Could you please provide a similar blog without repeating table but with fields like rich text box, drop downs, date etc submittion of infopath to sharepoint list. It would be really helpful as many of the previous comments from users require the solution for this. Thanks.

  • easy to see… about your tutorial… very clear step by step http://www.pembolang.com

  • CLockeWork says:

    Hi Scott,

    I know I'm pretty late to the party on this thread but I was hoping you still may be able to help:

    I'm hoping to use the idea behind this walkthrough to create a SharePoint Form Library form that submits a section of it's data to a separate list.

    I'm building a purchase order form and need to be able to submit the item details to a specific list for reporting purposes. I need to be able to have a repeating table that allows users to add new line items but the function is grayed out in the repeating table created here.

    I have tried wrapping the repeating table in a repeating section but that just duplicates the same data. I've been trying to find a solution to this for a week now, trying many hideous work arounds, and your walkthough has gotten me so close to an elegant solution so your help would be invaluable.

    Thanks either way,

    Oz

    (P.S – I'm running Infopath 2013 and SharePoint 2010, I'm hoping that doesn't make too much of a difference)

  • Scott Heim says:

    Hi CLockeWork,

    Are you saying that you added a Repeating Table (or Section) to your Form Template and when you attempt to add a new row, that option is grayed out? If so, how did you design your Form Template? Did you start by launching InfoPath and choosing Blank Form or are you customizing a SharePoint list?

    Scott

  • CLockeWork says:

    Hi Scott,

    Sorry for the slow response.

    When I right click on the repeating table in design and Repeating Table Properties the options for allowing users to add extra rows is dissabled. Is this down to the nature of the connection not allowing me to send multiple list entries at once?

    I created a new blank form through infopath.

    Thanks

  • Scott Heim says:

    Hi ClockeWork,

    Can you try these steps for me:

    Do you see the option: "Aloow users to insert and delete the sections" ?

    Scott

  • Nate says:

    Hello. Thanks for this article.

    I think I'm getting hung up on one little aspect, if you could please help advise:

    I built my InfoPath form from an Access database. (So it has a data connection to an Access database).

    When I am creating the Submit function to my target list, i.e. Step 6, bullet #3…

    My version of the "ListName" comes up as "/dfs:myFields/my:ListName" AS OPPOSED to "my:myFields/my:ListName"

    Do you think this is what's holding me up? And what would you recommend doing?

    My InfoPath is not producing any error messages; it seems to work just fine… Except that no data is published to the List. It just says that it was submitted, and clears the data entry fields, but then nothing is added to the List.

    Thanks for your help.

    -Nate

  • CPT Ryan Rothchild, US Army says:

    Gentlemen,

    I found your post extremely helpful in teaching myself to create forms which will update Sharepoint Lists.  However, through no fault of your post, my forms failed to update the list.  My server is forscom2.bliss.army.mil, so I am using a secured Sharepoint site.  I followed all of the steps above exactly as typed and my form's submission was successful (meaning the infopath form responded that submission to the Sharepoint list was successful).  However, the data from the form did not populate the list.  What should I do?

  • Scott Heim says:

    CPT Ryan Rothschild,

    There are a number of reasons why your data may not be showing in your list. I know there are a lot of comments on this post but I would encourage you to go through them as I have addressed most all reasons. The other thing I would encourage, if you are not doing so, is to test the process with a test list where all columns are defined as "Single line of text."  These are the easiest to allow you to make sure your process works. For instance, if you have a column define as date and time, it must be formatted a certain way (which I cover in various comments on this post) or the data will simply not appear. So using just text columns to get the process working first is the easiest way. If nothing else, it rules out one of the reasons for failure.

    Scott

  • Scott Heim says:

    Hi Nate,

    Your issue (and my reply :)) is the same as what I posted for CPT Ryan Rothschild – take a look through the comments. The "XPATH" expression (dfs:myFields) will not impact this process unless you are not referencing the correct XPATH from your form template. Most likely it is due to one of the known causes that I have mentioned in prior comments.

    Scott

  • Sangeet Ahuja says:

    Thanks for your post. It works for simple text fields.

    BUT it does not work for User or Date type field.

  • Scott Heim says:

    Hi Sangeet,

    Actually it does work for those field types and others as well – you just have to make sure they are formatted the way SharePoint needs to receive the data. I know there are a lot of comments on this post but if you read through the comments there are steps on how to do what you need.

    Scott

  • Jason says:

    Scott,

    I am experiencing the similar issue of submitting the form and it saying successful but no data shows.  I found in the sharepoint logs this message:

    High     Batchmgr Method error. Errorcode: 0x1dafa7d0. Error message: One or more field types are not installed properly. Go to the list settings page to delete these fields. bd199282-2854-4d89-b719-11b1c1d94b76

    I stepped down one by one removing fields I continue to get this message until all of the columns are gone.  I feel this is possibly related to the title column but no matter which ones I delete or in what order I still see this message. All of my columns are "single line of text"

    Do you anyone else on here possibly have an idea of where I might be going wrong.  The form will retrieve data from the list but wont write data.

    I read thru a lot of the comments with users experiencing this same issue but none posted anything about finding anything with there field types being wrong.

    Thank you

  • Jason says:

    Scott,

    I figured it out but only with the help you provided to another post about 20 pages deep.   just for reference in 2010 you have to add a rule to get to the conditional formatting options.

    What this will do is prevent the Title field from showing in this repeating table. Now, you can submit items without a title but, by default, the title field shows in the list and a new item without a title shows: "No Title."

    This solved my problem.  Im still a little confused on how but im not that concerned with it.

  • bronyx says:

    Hi,

    I have slightly changed your instructions here, and the weird thing is that is works in the info path client (Preview Mode) and not in the browser.

    What I did was created a InfoPath from based on sharepoint List. For e.g. lets call this list List A.

    I customized the form for List A and want to add items from List A to List B.

    I created a new column on the Main (List A) in InfoPath and set its default value to the ID of List B and I set the web service up.

    Everything works ok, i.e I can submit the List A form and it submits items to List B using InfoPath (Preview Mode)… But in the Browser, I get the following error

    "An Error Occurred while trying to connect to a web service. An entry has been added to the windows log of the server"

    I cant put my finger on what is causing this, because it works ok when in the Preview Mode of InfoPath..

    Any Ideas?

    Thanks

  • Confused and dismayed says:
    1. Select the “UpdateListItems” operation

    How? How? How?

  • DG2g1 says:

    Is there any way to only show the items the logged in user created on the current day?

  • Scott Heim says:

    Hi DG2g1,

    If you are using InfoPath 2010 or later, you can actually use the "queryFields" to add a filter to the data connection so it will only return those items that have been entered for the current day.

    Scott

  • Scott Heim says:

    Hi bronyx,

    On your SharePoint server, enable "Verbose" logging for InfoPath Forms Services. Then reproduce the error and check the ULS logs – you should get sufficient information to point you in the direction of the error.

    If you have a SharePoint farm that contains multiple web front ends, then chances are you are failing because of an authentication "hop" – meaning this: the InfoPath form was opened on Web Front End A – when the data connection was executed, it came back in through your load balancer which routed this request to Web Front End B – if that is the case, that is an NTLM authentication hop which is not allowed.

    But this is mere speculation until you get more details about the actual error.

    Scott

  • Scott Heim says:

    Hi Confused and dismayed,

    If you did step 1 and clicked the Next button then you will see the list of operations available to you, one of which is UpdateListItems.

    Scott

  • Zubair says:

    I tried but i am getting error

    Some rules were not applied?

  • Scott Heim says:

    Hi Zubair,

    That is not anywhere near enough information for me to provide any suggestions other than…the steps in the blog work. If you are having problems, start fresh and follow the steps exactly as I have them. If you still run into a problem then please provide more information other than you're getting an error.

    Scott

  • Dominic says:

    Is there any way of submitting this to a list with anything other datatypes than single line of text?

  • Scott Heim says:

    Hi Dominic,

    Yes – peruse all the comments as there are numerous entries about how to do this.

    Scott

  • Scott says:

    Haha thanks Scott, I didn't see that there was a more comments option.

    I've checked and now that I have found them all. I'm thinking there is no way of making this work for a content_type: Event, so that I can use a form to add to a Sharepoint Calendar. (even though this comes under lists)

  • Scott Heim says:

    So I have successfully submitted items to a Calendar via this method but just using the built-in column types (i.e. DateTime, Single Line of Text, Number, etc.) I've not tried adding something outside of those.

    Scott

  • Dominic says:

    I have:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name='Title'></Field>

           <Field Name="Start_Time">2013-07-11 12:00:00</Field>

           <Field Name='End_Time'>2013-07-11 12:00:00</Field>

       </Method>

    </Batch>

    and in Sharepoint:

    Column (click to edit) Type Required  

    Title  Single line of text   Required

    Location  Single line of text  

    Start Time  Date and Time   Required

    End Time  Date and Time   Required

    Description  Multiple lines of text  

    Created By  Person or Group  

    Modified By  Person or Group  

  • Scott Heim says:

    Hi Dominic,

    So if you are using the built-in Calendar columns, then the problem you are having is "Start Time" and "End Time" are NOT the actual underlying names for those columns – they are:

    EventDate

    EndDate

    I realize this is not obvious so to see all the actual names, you can do this:

    I would also suggest you test this in "steps" – have your XML file only be for the "required" columns (Title, EventDate and EndDate) – once you have this working, then add others.

    Scott

  • Dominic says:

    Thanks Scott, that's explained everything.

    Don't suppose you came across how to make it an all day event, using infopath?

    If not, no worries. Will try it out.

    Kind Regards,

  • Scott Heim says:

    Hey Dominic – unfortunately I have not tried that. 🙁

  • Dominic says:

    Found it.

    I looked at the sharepoint form source code and found the name as fAllDayEvent – Yes/No = 1/0

    So I plugged this is to my CAML:

    <Field Name="fAllDayEvent">1</Field>

    Thanks again for all the help.

    Dom

  • Scott Heim says:

    Hi Dominic,

    That's great to hear!

    Scott

  • Nandini says:

    Hi Scott ,

    Thanks alot for the wonderful post , I have implemented this successfully. Here we are using InfoPath form for New form , How can have the same functionility for the Edit form in the list too? . If I customize the list using Infopath form , it ll have lot of limitations. Is this possible to extent this to edit form also?

    Thanks and Regards,

    Nandini Prasad

  • Scott Heim says:

    Hi Nandini,

    This method is simply for taking data from an InfoPath form and adding/updating a SharePoint list. If you are using SharePoint 2010 and InfoPath 2010, then you can simply "customize" your form for a specific list using InfoPath. For example:

    This will launch InfoPath and you can customize the form, publish it back to that list and now your InfoPath form will be used for the Display, New and Edit forms.

    Note there are some limitations for this:

  • The form will only submit to this one list. You may be able to add similar functionality to what this blog post describes but again, no code

  • Scott

    Reply
  • Nandini says:

    Thanks alot for th reply Scott. yes I am using SharePoint 2010   , because of the limitations enforced by List customized using Infopath forms , I am looking at this approach. I am just able to design this form different rather than just inserting the secondary data repeating table as you have shown in the example. Is there any way we can redesign this form?

    Regards,

    Nandini

  • Scott Heim says:

    Hi Nandini,

    You cannot take a standard InfoPath form and make it into a form used in a SharePoint list. So what you may be able to do is:

    Scott

  • Ashley says:

    Hi,

    Are you able to use this form to update the information already in the list? Can you make changes in the display and when you hit the submit button it will submit the change to the list?

  • Scott Heim says:

    Hi Ashley,

    Yes – with a few modifications. I know there are a lot of comments but if you go through them you will find sample steps on how to use the process to update existing list items.

    Scott

  • Ashley says:

    Thanks Scott,

    I found your post from Oct 8, 2007 for writing the code. You said you added a new column with a button that would be used to update the row. Did you add this column after you already made the repeating table off of the MyContacts list? So will there be a button for each row? I need to be able to edit and delete the current items in the list.

    Right now I have a drop down that allows the user to select a value then the form displays the data from the sharepoint list for that value. Then I have the table where the user can add a new item and hit the button to submit the new item.

    Thanks!

  • Ashley says:

    I actually think I figured that part out. The question I have is where does the code go for the public void? Is this vba or #C?

  • Scott Heim says:

    Hi Ashley,

    It is C# and it would go on a button click event so when the button is clicked, it would execute the code to update the item you have specified.

    Scott

  • Ashley says:

    Great thanks Scott. This is the last question, sorry! I saw someone in an earlier post had the same problem but I get the error "the name 'e' does not exist in the current context". After researching it a bit it seems that the name needs to be declared before being called? Do you know how to fix this? The part of the code it pertains to is below:

    public void InternalStartup()

    {

    ((ButtonEvent)EventManager.ControlEvents["UpdateList"]).Clicked += new ClickedEventHandler(UpdateList_Clicked("Update", e.Source.CreateNavigator()));

    }

    public void UpdateList_Clicked(string strOperation, XPathNavigator e)

    {

       //Create a new instance of our "Lists" web service

       ServerName.Lists myList = new ServerName.Lists();

  • Scott Heim says:

    Ashley – please post all your code so I can see what you have.

    Thanks…

  • Ashley says:

    public void InternalStartup()

    {

    ((ButtonEvent)EventManager.ControlEvents["UpdateList"]).Clicked += new ClickedEventHandler(UpdateList_Clicked("Update", e.Source.CreateNavigator()));

    }

    public void UpdateList_Clicked(string strOperation, XPathNavigator e)

    {

     //Create a new instance of our "Lists" web service

     ServerName.Lists myList = new ServerName.Lists();

     //Pass the logged on users credentials to the web service

     myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

     //Create a DataSource object for our list data source

     DataSource dsContacts = this.DataSources["Updated Headcount"];

     //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

     XmlNamespaceManager ns = this.NamespaceManager;

     //Create XPathNavigator objects for each field from our list

     XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

     XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

     XPathNavigator xnLastName = e.SelectSingleNode("@LastName ", ns);

     XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

     XPathNavigator xnFranchise = e.SelectSingleNode("@Franchise", ns);

     XPathNavigator xnLocation = e.SelectSingleNode("@Location", ns);

     XPathNavigator xnPillar = e.SelectSingleNode("@Pillar", ns);

     XPathNavigator xnLeader = e.SelectSingleNode("@Leader", ns);

     XPathNavigator xnActivity = e.SelectSingleNode("@Activity", ns);

     XPathNavigator xnCategory = e.SelectSingleNode("@Category", ns);

     XPathNavigator xnPosition = e.SelectSingleNode("@Position", ns);

     XPathNavigator xnDeptNumber = e.SelectSingleNode("@DeptNumber", ns);

     XPathNavigator xnSupervisor = e.SelectSingleNode("@Supervisor", ns);

     XPathNavigator xnEmployeeType = e.SelectSingleNode("@EmployeeType", ns);

     XPathNavigator xnFTE = e.SelectSingleNode("@FTE", ns);

     XPathNavigator xnNotes = e.SelectSingleNode("@Notes", ns);

     //Create a new XmlDocument to use for specifying the Update CAML query

     XmlDocument doc = new XmlDocument();

     //Create the needed update element

     System.Xml.XmlElement updates = doc.CreateElement("Batch");

     //Create the CAML query passing in the value of each of our fields from the form

     if (strOperation == "Delete")

     {

       updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Delete'>" +

       "<Field Name='ID'>" + xnID.Value + "</Field>" + "</Method>");

     }

  • Ashley says:

    else

    {

     //Create the CAML query passing in the value of each of our fields from the form

     updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Update'>" +

     "<Field Name='ID'>" + xnID.Value + "</Field>" +

     "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

     "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

     "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

     "<Field Name='Franchise'>" + xnFranchise.Value + "</Field>" +

     "<Field Name='Location'>" + xnLocation.Value + "</Field>" +

     "<Field Name='Pillar'>" + xnPillar.Value + "</Field>" +

     "<Field Name='Leader'>" + xnLeader.Value + "</Field>" +

     "<Field Name='Activity>" + xnActivity.Value + "</Field>" +

     "<Field Name='Category'>" + xnCategory.Value + "</Field>" +

     "<Field Name='Position>" + xnPosition.Value + "</Field>" +

     "<Field Name='DeptNumber'>" + xnDeptNumber.Value + "</Field>" +

     "<Field Name='Supervisor'>" + xnSupervisor.Value + "</Field>" +

     "<Field Name='EmployeeType'>" + xnEmployeeType.Value + "</Field>" +

     "<Field Name='FTE'>" + xnFTE.Value + "</Field>" +

     "<Field Name='Notes'>" + xnNotes.Value + "</Field>" + "</Method>");

    }

     //Update the list

     XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

     XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

     //Requery the data source to reflect the updates

     dsContacts.QueryConnection.Execute();      

    }

  • Scott Heim says:

    Thanks Ashley…so how are you getting that code into the "InternalStartup" procedure? Are you hand entering that? What happens if you:

    What you have in InternalStartup does not seem correct.

    Scott

  • Ashley says:

    Yeah that's what I did originally but I think I got confused as to where to put the UpdateList("Update",e.Source.CreateNavigator) versus the rest of the code. Now when I go to right click on the button and hit edit form code, it won't open.

  • Scott Heim says:

    Ashley – delete what you have in InternalStartup then redo the steps from the button.

    Scott

  • Ashley says:

    Now it's saying that the "UpdateList" name does not exist in the current context. You said the only line in the Clicked event is the UpdateList("Update", e.Source.CreateNavigator()); correct? then do I just copy the procedure for UpdateList below that? Thanks so much for helping me out, I've been struggling with this for days!!

    public void InternalStartup()

    {

     ((ButtonEvent)EventManager.ControlEvents["UpdateList"]).Clicked += new ClickedEventHandler(UpdateList_Clicked);

    }

    public void UpdateList_Clicked(object sender, ClickedEventArgs e)

    {

     UpdateList("Update", e.Source.CreateNavigator());

    }

    public void UpdateList_Clicked(string strOperation, XPathNavigator e)

    {

  • Scott Heim says:

    Ashley,

    When you click the Edit Form Code button it takes you to the code and, by default, it will look like this:

    public void CTRL1_5_Clicked(object sender, ClickedEventArgs e)

    {

       // Write your code here.

    }

    ** The name will probably not be CTRL1_5 but other than this, it should look like what is above.

    Where is shows "//Write your code here" – here is what you should have there:

    UpdateList("Update", e.Source.CreateNavigator());

    So now, the clicked event should look like this:

    public void CTRL1_5_Clicked(object sender, ClickedEventArgs e)

    {

        UpdateList("Update", e.Source.CreateNavigator());

    }

    Then just below the "closing brace" in the above procedure (the closing brace is the "}"), you need to have this entire procedure:

    public void UpdateList(string strOperation, XPathNavigator e)

    {

        //All the code from this procedure

    }

    Scott

  • Ashley says:

    thank you! it was only an error with one of the names. There are no more errors when I debug the code but now when I try to make an edit in the repeating table I get the following error:

    Object reference not set to an instance of an object.

      at Updated_Headcount.FormCode.UpdateList(String strOperation, XPathNavigator e)

      at Updated_Headcount.FormCode.UpdateList_Clicked(Object sender, ClickedEventArgs e)

      at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)

      at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

  • Scott Heim says:

    Hey Ashley,

    This is where you are going to need to know some code or this is going to be somewhat painful. Chances are the "XPATH" expressions in your code are not correct. But to find out why this fails you will need to debug your code. So you need to make sure you are building for Debug mode and not release then you can add a breakpoint in your code, start in debug mode and then step through the code to see exactly which line fails and why.

    Scott

  • Ashley says:

    Okay, thanks so much Scott for your help!

  • kaushal says:

    Hi,

    Thanks for your post but need your help.

    I am just trying to submit data to sharepoint list using webservice like you suggested but i can new item added in sharepoint list but it is blank.

    Plz help me.

  • Kaushal says:

    Hi,

    Thanks for your post but need your help.

    I am just trying to submit data to sharepoint list using webservice like you suggested but i can new item added in sharepoint list but it is blank.

    Plz help me.

  • Sporto says:

    Hello,

    What does the SharePoint list look like after the InfoPath Form is submitted?  I would be nice to see a screen shot of how the table looks in the Columns of the list.  Thanks.

  • kaushal says:

    Hi,

    I am not able to attach any screenshot over here so if possible can me give me email address.My email id is kaushalbagrodia@yahoo.com

  • Andy says:

    HI,

    I am using your code on 15th page which can be used for non repeating fields. But its not working correctly.

    Is there anyway i can add non repeating field value to sharepoint list without using code.

    Thanx

  • Scott Heim says:

    Hi Andy,

    Not sure I follow: the code can be modified to work with repeating or non-repeating fields. In addition, you can easily add data from non-repeating fields without using code… if I recall correctly, there are samples of this in the comments (it's been a while so I don't recall 100%) – but with a slight modification of the code (using an XpathNavigator object instead of an XpathNodeIterator object), it would work as well.

    Scott

  • Andy says:

    Hi,

    This was your comment.

    Here are the new steps – and again these will only work using the InfoPath client. (NOTE: I would suggest you first create a new sample XSN to make sure this works and then implement this in your actual XSN.)

    This update will still follow the same basic steps outlined in this blog post except for step #7.

    ………………….

    …….

  • Locate the following node in the file: <xsf:ruleSets>

  • Directly under this node, you will see the “sample” Rule that we created above as follows:

  • <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

  • Repeat the above step three more times so you have a total of five lines that have the same information (the number of lines you have here correspond to the number of fields in your Add List Item Template.xml file)

  • Add an “index” to each “Field” node, like this:

  • <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field[1]" expression="my:gpContacts/my:_Title"></xsf:assignmentAction>

    When you are done you the index number should be incremented for each "field" (i.e. [1], [2], etc.)

    For each line, change: my:gpContacts/my:_Title to point to the correct node that we added (i.e. _Title, _FirstName, etc.)

    NOTE: It is very important that your “expression” nodes are in the same order as what you have in your Add List Item Template.xml file. In this sample, “Field[1]” is Title, “Field[2]” is FirstName, etc. Also – like all XML, capitalization must also match what you have in your data source.

    Reply
  • Andy says:

    So i am using this solution to submit nonrepeating fields to submit to sharepoint list. But i guess i am doing something wrong at this step:

    For each line, change: my:gpContacts/my:_Title to point to the correct node that we added (i.e. _Title, _FirstName, etc.)

    So can you tell me exactly what would be changed expression line for _Title.

    I would appreciate your help sincerely.

    Also pasting the changed content of .xsf file below …

    <xsf:ruleSet name="ruleSet_1">

            &lt;xsf:rule caption=&quot;Rule 1&quot; isEnabled=&quot;yes&quot;&gt;
    
                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field&quot; expression=&quot;my:gpcontacts/my:_Title&quot;&gt;&lt;/xsf:assignmentAction&gt;
    

    <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field[1]" expression="my:_Title"></xsf:assignmentAction>

                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field&quot; expression=&quot;my:gpcontacts/my:_FirstName&quot;&gt;&lt;/xsf:assignmentAction&gt;
    

    <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field[2]" expression="my:_FirstName"></xsf:assignmentAction>

                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field&quot; expression=&quot;my:gpcontacts/my:_LastName&quot;&gt;&lt;/xsf:assignmentAction&gt;
    

    <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field[3]" expression="my:_LastName"></xsf:assignmentAction>

                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field&quot; expression=&quot;my:gpcontacts/my:_Email&quot;&gt;&lt;/xsf:assignmentAction&gt;
    

    <xsf:assignmentAction targetField="xdXDocument:GetDOM("Add List Item Template")/Batch/Method/Field[4]" expression="my:_Email"></xsf:assignmentAction>

                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field&quot; expression=&quot;my:gpcontacts/my:_Phone&quot;&gt;&lt;/xsf:assignmentAction&gt;
    
                &lt;xsf:assignmentAction targetField=&quot;xdXDocument:GetDOM(&quot;Add List Item Template&quot;)/Batch/Method/Field[5]&quot; expression=&quot;my:_Phone&quot;&gt;&lt;/xsf:assignmentAction&gt;
    
            &lt;/xsf:rule&gt;
    
        &lt;/xsf:ruleSet&gt;
    
    &lt;/xsf:ruleSets&gt;
    
  • scot says:

    First of all thank you scott i learnt a lot from this post,But i am stuck at one place is that i want to add multiple rows of repeating table at one submit button click, Can you help me?

    Big Thanx in Advance.

  • Bill F says:

    Actually, similar question as Scot on the multiple rows.

    I know that if I create my form in infopath and publish it as a template I could add custom code to handle creating a new node in the CAML xml. Then each row in a repeating table could be used to create a new update node.

    Still, I'd like to avoid having any attached code if at all possible.

  • Scott Heim says:

    Bill F: the only way to add rows to a repeating structure is through code – this cannot be done via a Rule.

    Scot: adding multiple rows using code is not specific to what this we're doing in this post. Just search the Internet for how to add rows to an InfoPath repeating table using C# and you should get plenty of information. Then just incorporate that into this solution. I may have some of that type of sample code in the various comments on this post. Have you checked?

    Scott

  • nain says:

    how to add multiple records into sharepoint list (multiple fields when user is given insert new item)

  • Scott Heim says:

    Hi Nain,

    You have to use code to iterate over the rows in your repeating table. Take a look through the comments on this post – there is sample code to do this.

    Scott

  • Chris Dixon says:

    I get and error message when I attempt this.

    InfoPath cannot submit the form.

    An error occurred while the form was being submitted.

    The SOAP response indicates that an error occurred on the server:

    Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

    <detail><errorstring xmlns="schemas.microsoft.com/…/">

       List does not exist.

       The page you selected contains a list that does not exist.  It may have been deleted by another user.

       </errorstring><errorcode xmlns="schemas.microsoft.com/…/detail>

  • Scott Heim says:

    Chris – when you add the data connection to the Lists web service, you have to add it at the appropriate level. Let me give you some examples:

    You need to make sure your web service connection is pointing to the same site location as to where the list resides.

    Scott

  • Chris Dixon says:

    Hello Scott,

    BTW, thanks for assist me. If I understand this right you are referring to the GUID?

    Here is where the list resides:

    http://Server/ws/adm2/_layouts/listedit.aspx?List=%7BF85D231D%2D544C%2D4E78%2DAA41%2D6D1F70BE054E%7D

    I've translated the List to = {F85D231D-544C-4E78-AA41-6D1F70BE054E} and made the value of the ListName node to that. The ListName is located under Main

    I did notice that I name my Sharepoint List "My Contacts" instead of "MyContact", but I would think that matters

  • Scott Heim says:

    Hi Chris,

    What I am referring to is the web service connection you create to submit to the list. Based on the URL you provided, your web service connection URL should look like this:

    http://Server/ws/adm2/_vti_bin/lists.asmx

    I am referring to step 6 in the steps.

    Scott

  • Chris Dixon says:

    Ahhh…, that worked. Is there a way to apply to method to an existing infopath form that submits to a form library and capture certain field in the form to the Datasheet view of the library if that makes any sense?

  • Scott Heim says:

    Hi Chris,

    Glad that worked for you. 🙂  However, I am not clear on your next question – can you provide some additional details?

  • Chris Dixon says:

    No worries Scott, I answered my own question too late in the day my brain is about 30mins to shutdown.

  • Chris Dixon says:

    Well, Scott I do have one other question. Will this work on existing items in a list? For example I have a  Employees List and as user fill of the form I was it to capture the address and update the Employee's information in the list like Address etc.

  • Chris Dixon says:

    Here is the CAML that im creating the Employees is Group/People picker field

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="New">

           <Field Name='Employees'></Field>Home Address Street

        &lt;Field Name=&quot;Home Address Street&quot;&gt;&lt;/Field&gt;
    

           <Field Name="Home Address City"></Field>

           <Field Name="Home Address State Or Province"></Field>

           <Field Name="Home Address Postal Code"></Field>

    &lt;Field Name=&quot;Mobile Number&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;iPad Password&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;iTunes Email Address&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;iTunes Password&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Net Password&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Evolution Password&quot;&gt;&lt;/Field&gt;
    

       <Field Name="Manager's Name"></Field>

       </Method>

    </Batch>

  • Scott Heim says:

    Hi Chris,

    If you look through all the comments (I know there are a bunch) I have sample code for updating existing items in a list. The CAML "Cmd" needs to be changed to "Update" instead of "New" – "new" adds items to a list, "update" is what you use to update existing items. However, you also have to know the SharePoint ID of the item you want to update.

    Poke through the comments – you should find what you need.

    Scott

  • Chris Dixon says:

    Hello Scott,

    Is this the code you are referring too for updating an existing list? Just need to change varibles to match my columns. This is what consist in the CAML file?

    Then you need the "UpdateList" procedure as follows:

    public void UpdateList(string strOperation, XPathNavigator e)

         {

              //Create a new instance of our "Lists" web service

              sheimserver.Lists myList = new sheimserver.Lists();

              //Pass the logged on users credentials to the web service

              myList.Credentials = System.Net.CredentialCache.DefaultCredentials;

              //Create a DataSource object for our list data source

              DataSource dsContacts = this.DataSources["MyContacts"];

              //Create a NamespaceManager object so we can use the various namespaces on our XPATH expressions

              XmlNamespaceManager ns = this.NamespaceManager;

              //Create XPathNavigator objects for each field from our list

              XPathNavigator xnID = e.SelectSingleNode("@ID", ns);

              XPathNavigator xnFirstName = e.SelectSingleNode("@FirstName", ns);

              XPathNavigator xnLastName = e.SelectSingleNode("@LastName", ns);

              XPathNavigator xnTitle = e.SelectSingleNode("@Title", ns);

              XPathNavigator xnEmail = e.SelectSingleNode("@Email", ns);

              XPathNavigator xnPhone = e.SelectSingleNode("@Phone", ns);

              //Create a new XmlDocument to use for specifying the Update CAML query

              XmlDocument doc = new XmlDocument();

              //Create the needed update element

              System.Xml.XmlElement updates = doc.CreateElement("Batch");

              //Create the CAML query passing in the value of each of our fields from the form

              if (strOperation == "Delete")

              {

                  updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Delete'>" +

                  "<Field Name='ID'>" + xnID.Value + "</Field>" + "</Method>");

              }

              else

              {

                  //Create the CAML query passing in the value of each of our fields from the form

                  updates.InnerXml = string.Format(@"<Method ID='1' Cmd='Update'>" +

                  "<Field Name='ID'>" + xnID.Value + "</Field>" +

                  "<Field Name='FirstName'>" + xnFirstName.Value + "</Field>" +

                  "<Field Name='LastName'>" + xnLastName.Value + "</Field>" +

                  "<Field Name='Title'>" + xnTitle.Value + "</Field>" +

                  "<Field Name='Phone'>" + xnPhone.Value + "</Field>" +

                  "<Field Name='Email'>" + xnEmail.Value + "</Field>" + "</Method>");

              }

              //Update the list

              XPathNavigator xnListGUID = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:ListName", ns);

              XmlNode node = myList.UpdateListItems(xnListGUID.Value, updates);

              //Requery the data source to reflect the updates

              dsContacts.QueryConnection.Execute();

          }

  • Scott Heim says:

    Hi Chris – yes…this code would need to match your field names and what you have in the CAML file. If you have trouble implementing this, I would encourage you to make a test list with exact names like this sample so you can see it work.

    Scott

  • Chris Dixon says:

    Hello Scott,

    Happy St.Patty's Day

    So, I still need more direction on what I'm possibly missing or doing wrong. As suggested I've created a Sharepoint Test List. Below are my steps.

    Step 1.

    List called "Employee" with the following fields

    1. Name
    2. Home Address Street

    3. Home Address City

    4. Home Address State Or Province

    5. Home Address Potal Code

    6. Manager's Name

    Step 2.

    Secondly, I've created a new infoPath Filler Form and added the "Employee" List as a secondary data connection. Also, added the CAML file: "Add List Item Template" data connection.

    CAML File:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="Update">

    &lt;Field Name=&#39;Name&#39;&gt;&lt;/Field&gt;
    

           <Field Name="Home_Address_Street"></Field>

           <Field Name="Home_Address_City"></Field>

           <Field Name="Home_Address_State_Or_Province"></Field>

           <Field Name="Home_Address_Postal_Code"></Field>

    &lt;Field Name=&quot;Mobile_Number&quot;&gt;&lt;/Field&gt;
    
    &lt;Field Name=&quot;Manager_s_Name&quot;&gt;&lt;/Field&gt;
    

       </Method>

    </Batch>

  • Chris Dixon says:

    Step 3.

    I created the "ListName" control with the GUID from the List Settings of the "Employee" List.

    Step 4.

    Created the Web Service Submit Data Connection http://Server/Site/_vti_bin/lists.asmx?WSDL, and selected "UpdateListItems." Pointed the tns:listName to the "ListName" control under myFields and pointed the tns:updates to /Batch  under the Add List item Template.

    Step 5.

    Dragged and Dropped the below fields from "Employee" List to the form. Also, dragged and dropped "Name" and "Field" from Add List Item Template secondary data connection.

    1. Name

    2. Home Address Street

    3. Home Address City

    4. Home Address State Or Province

    5. Home Address Potal Code

    6. Manager's Name

  • Chris Dixon says:

    Step 6.

    Added a control button and set it to "Always Excutes" Rule with the following actions:

    Submit using a data connection: "Web Service Submit Batch"

    Query using a data connection: "Employee"

    I then applied the following code to the VB Code on the button, which generated 202Errors

  • Chris Dixon says:

    Scott,

    The code is too big to post I can send it via email. Here is my email address if it's ok with you to email me and I'll email you the code.

    chris_dixon22@hotmail.com

  • Chris Dixon says:

    Also, from another source I read that I have to create Web Service for each of the fields I would be updating.

    Therefore, I've created additional web service submit to each fields in the Employee List. They are setup similiar to the "Web Service Submit Batch."  I set a action Submit data to the below data connections as well but i've since removed them for now.

    "Web Service Submit Street"

    "Web Service Submit City"

    "Web Service Submit State"

    "Web Service Submit Zip"

    "Web Service Submit Manager"

  • Scott Heim says:

    Hey Chris,

    A few things:

    1) Be sure you are actually using VB.NET code – most of the samples I provided are C#.NET

    2) You have spaces in your SharePoint column names – this is going to cause you potential headaches. And you cannot just rename them as the underlying column name will still contain the space. 🙁  So here is what I suggest to make sure you have the field names in the CAML file correct:

    Now, this will not effect your code errors – just trying to head off another issue I see. 🙂

    Scott

  • Chris Dixon says:

    Ok I give that a try momentarily. Thanks

  • Chris Dixon says:

    Hello Scott,

    I can see when I'm creating the receive data connection to the list that the fields with spaces have a underscore. I figured this would be a problem. I still will do as you suggested I just want to mention that.

    Example: Home Address Street = (Home_Address_Street)

  • Chris Dixon says:

    Ahhh…, no spacesin the manifest.xsf file shows like this

                    &lt;xsf:field internalName=&quot;Title&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;HomeAddressStreet&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;HomeAddressCity&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;HomeAddressStateOrProvince&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;HomeAddressPostalCode&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;ManagersName&quot; required=&quot;no&quot; type=&quot;Text&quot;&gt;&lt;/xsf:field&gt;
    
                    &lt;xsf:field internalName=&quot;ID&quot; required=&quot;no&quot; type=&quot;Counter&quot;&gt;&lt;/xsf:field&gt;
    
  • Chris Dixon says:

    Ok, so I changed the CAML file to match the fields. I'm in the code edior notw for te Submit button. See Below , I have not added any coding yet. Where would the code go? Underneah the Namespace pdateListTest Or under Pulic Sub CTRL10_5_Clicked…..

    Namespace UpdateListTest

       Public Class FormCode

           ' Member variables are not supported in browser-enabled forms.

           ' Instead, write and read these values from the FormState

           ' dictionary using code such as the following:

           '

           ' Private Property _memberVariable() As Object

           '     Get

           '         _memberVariable = FormState("_memberVariable")

           '     End Get

           '     Set

           '         FormState("_memberVariable") = value

           '     End Set

           ' End Property

           ' NOTE: The following procedure is required by Microsoft InfoPath.

           ' It can be modified using Microsoft InfoPath.

           Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

               AddHandler DirectCast(EventManager.ControlEvents("CTRL10_5"), ButtonEvent).Clicked, AddressOf CTRL10_5_Clicked

           End Sub


           Public Sub CTRL10_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

           End Sub

       End Class

    End Namespace

  • Scott Heim says:

    Chris – the ability to successfully get this to work requires some coding knowledge – without that, you're really jumping into the 10' end of the pool without knowing how to swim.

    The code project you have looks like VB and I believe my code samples are C# (if I recall correctly.) If this is the case, you will need to use the InfoPath UI to remove the current code project and add a new one for C#. Then the code I provided will go into the button click event.

    Scott

  • Chris Dixon says:

    Yes, I have some programming knowledge the Infopath was set to VB as default I just changed it to C# and here is what I get on the Submit button now.

    using Microsoft.Office.InfoPath;

    using System;

    using System.Windows.Forms;

    using System.Xml;

    using System.Xml.XPath;

    using mshtml;

    namespace UpdateListTest

    {

       public partial class FormCode

       {

           // Member variables are not supported in browser-enabled forms.

           // Instead, write and read these values from the FormState

           // dictionary using code such as the following:

           //

           // private object _memberVariable

           // {

           //     get

           //     {

           //         return FormState["_memberVariable"];

           //     }

           //     set

           //     {

           //         FormState["_memberVariable"] = value;

           //     }

           // }

           // NOTE: The following procedure is required by Microsoft InfoPath.

           // It can be modified using Microsoft InfoPath.

           public void InternalStartup()

           {

           }

       }

    }

  • Scott Heim says:

    Hey Chris – that's good to hear. The code project now looks good. 🙂  I would add your own button (at least for testing purposes) and use the sample code in this post on the click event of the button.

    Scott

  • Chris Dixon says:

    Ok, Scott I think I'm close  get 1 error

    Error 1 Type 'UpdateListTest.FormCode' already defines a member called 'InternalStartup' with the same parameter types \serverpathpathmeInfoPath ProjectsUpdateListTest1FormCode.Designer.cs 29 21 UpdateListTest

    When I click the Error it takes me to the FormCode.cs tab and highlights

    using Microsoft.Office.InfoPath;

    using System;

    using System.Windows.Forms;

    using System.Xml;

    using System.Xml.XPath;

    using mshtml;

    namespace UpdateListTest

    {

       public partial class FormCode

       {

           // Member variables are not supported in browser-enabled forms.

           // Instead, write and read these values from the FormState

           // dictionary using code such as the following:

           //

           // private object _memberVariable

           // {

           //     get

           //     {

           //         return FormState["_memberVariable"];

           //     }

           //     set

           //     {

           //         FormState["_memberVariable"] = value;

           //     }

           // }

           // NOTE: The following procedure is required by Microsoft InfoPath.

           // It can be modified using Microsoft InfoPath.

           public void InternalStartup()

           {

           }

       }

    }

  • Scott Heim says:

    Hey Chris – sounds like you have two "InternalStartup" methods defined? Maybe from a copy/paste scenario?

    Scott

  • Abeer says:

    I have a very similar situation as reported (and solved) by many of the other users in this blog.  I followed the instructions exactly as described however, I am showing a successful submit from the InfoPath Filler, but no entries in my sharepoint custom list.

    What am I missing??

  • Mahi says:

    Can we use this approach for updating external list(BCS). I am able to update SharePoint custom lists but not the external list. Do you  have any thoughts ?

    Thanks

    Mahi

  • Chris Dixon says:

    Hello Scott,

    I'm hoping you can help me again. I have a current form that submits to a Sharepoint List with a calendar view. The customer now wants the ability to have the form create weekly recurring meetings on the calendar. Therefore, I've created the following fields

    1.Repeat Every __ Week(s) On -Text Field (__)

    2.A checkbox for each day of the week M-F

    3.Start date – Date Picker field

    4.End Date- Date Picker field

    5.Start Time

    6.End Time

    I created the ListName/GUID but not the CAML file yet because I'm unsure how to code that correctly.

    Thanks, In advance for your help and direction on this

    Chris  

  • Mgauf says:

    Hello. I am able to successfully follow these instructions till 4. Double-click the “updates” parameter, select the “Add list Item Parameter” data source, select “Batch” and click OK in Step 6: Add the “lists.asmx” web service.

    Batch is not an option.

    Any help / suggestions would be appreciated.

  • Chandru says:

    Hello Scott, Is there a possiblity to submit the data along with attachment as well in this method? I want to create a list item with attachment in this way of submitting. Please let me know. Thanks

  • Scott Heim says:

    Sorry for the delay everyone…

    @Mahi: I honestly have never tried this and since an external list is based on the schema of, say, a SQL Server table I don't know if this process would work. If I get some time, I'll try and test this at some point.

    @Chris: I'll have to investigate this if I get some time.

    @Mgauf: The "batch" node comes from your "Add List Item Template" data connection. If you have selected that connection and you don't see the "batch" node then the XML file is not constructed correctly.

    @Chandru: Did a little testing with this and the only way I can see this working is with code. The reason is this: from the "Lists" web service there is an "AddAttachment" web method that can be easily called to create an attachment to a specified list item. The issue is one of the parameters is the attachment but as "base64Binary" not "base64String" which is how an attachment in InfoPath is stored. The only way I can think of to convert a base64String to base64Binary is using code.

    Scott

  • Michelle says:

    I have spent hours trawling around trying to find a solution to submit multiple items to a sharepoint list.  As I work for a company, I am limited to any coding as the build is locked down and I was really pulling my hair out.  This solution is a god send, thank you

  • Valerie says:

    This is completely unclear. You cannot add data connections to an xml file or a sharepoint list.

    1. 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.)

    2. 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.

  • Scott Heim says:

    Hi Valerie,

    Not sure I am following: from within InfoPath you can add data connections to XML files and SharePoint lists. Can you provide some additional detail around where you are not able to do this?

    Thanks,

    Scott

  • Warren says:

    Hi Scott – fantastic article – its really helped me add more functionality to my forms – Thank you!

    I notice this is an old post and I am hoping there have been some developments since this was originally posted. Like some of the other people that have posted here I am looking for a way in which to initiate a task in a separate list – without having to load that task list form. As pointed out by a few others the repeating table tied to CAML is quite lkimited when you want to add different controls. In particular the people picker control when you want to initiate a task in another list and fill out the Assigned To person. Have there been any developments or other methods found that will allow for this functionality?

    Again, many thanks for such an informative article.

    Warren

  • Scott Heim says:

    Hi Warren,

    Since this post was originally written, Microsoft has shipped Office/InfoPath versions 2010 and 2013. With these later versions you can create InfoPath forms directly against SharePoint lists. Those forms will be tied to the specific list and since managed code is not available with an InfoPath "list" form, the advanced steps in this particular post will not be of benefit.

    You can still use the information in this post if you create a standard InfoPath Form Template (i.e. not tied to a list) but the functionality of how you would add items to a list from a standard form has not changed.

    If you were to peruse the comments in this post there is the ability to use other types of controls; however, there is still not a way to place a "people picker" control on an InfoPath form and populate a "Person/Group" column in SharePoint – at least not directly. 🙂  What you can do is promote the "AccountId" node from the InfoPath form and then use a SharePoint Designer workflow to copy that value to the Person/Group column in your SharePoint list/library.

    I hope this information helps!

    Scott

  • Hadden says:

    Does anyone know how to apply this method to delete a list item?  I am using the advanced custom method with the CAML file. My code looks like this:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="Delete">

    &lt;Field Name=&quot;ID&quot;&gt;&lt;/Field&gt;
    

       </Method>

    </Batch>

    i Then set the field to equal the ID of the list item.

    I get the error that the Paramater is incorrect.

    Any Ideas?

  • A m a r says:

    Hello Scott Heim

    I have tried this on my sample form and it works fine, no issues at all.

    However, what could I do if I wanted to pass some default values to some of my fields like if I wanted to pass a value say now() to my "Title" field – would it be possible to pass. I have been struggling to do this but to no avail. Can you please help.

    Amar

  • Dushi says:

    Hi Scott,

    Firstly, I will give you the "url" to my list:

    https://site/sites/level1/level2/level3/level4/level5/level6/myList/AllItems.aspx

    Moving on, I followed this tutorial step by step and I've almost got it; I think the only problem I'm running into is in step 6:

    https://site/sites/level1/level2/level3/level4/level5/level6/myList/_vti_bin/lists.asmx?WSDL

    This does not exist. If you remove the "?WSDL", you can browse to it manually. But, you cannot add it into the data connection wizard (it automatically tries to add the "?WSDL").

    It doesn't exist for the next level down either:

    https://site/sites/level1/level2/level3/level4/level5/level6/_vti_bin/lists.asmx?WSDL

    But if you go one more level down, it works:

    https://site/sites/level1/level2/level3/level4/level5/_vti_bin/lists.asmx?WSDL

    I think it needs to be the first option (for the specific list) in order for it to update the list properly. But even if it's the second option, it simply doesn't exist with the "?WSDL" added on to the end of the page.

    I would like to leave Access out of this equation, if at all possible. To explain what I'm ultimately trying to accomplish:

    We have 200+ users who need to complete training monthly. Many of the users are spread out across 4 sites (not local to home), the remaining users are here at home. The training needs to be documented. So, instead of sending out an email saying "Read this and reply to me saying you've read it" (I don't want to get 200+ emails every month), I decided a SharePoint list would be the easiest way. To minimize the impact on the user, I want to send out a spreadsheet, InfoPath form, or whatever else may work where they simply need to put their name and the date they completed the training. They then click the submit button, and it adds the data they've typed into the form or spreadsheet to the list. They do NOT need to see the rest of the names added to the list already (this is how the tutorial I followed set it up) but, if there's no other way then so be it.

    Any assistance is GREATLY appreciated. Thank you in advance.

    -Dushi

    P.S. I am using InfoPath 2010.

  • Scott Heim says:

    @Hadden: This is the exact CAML I have in my "delete" template and it works fine when I set the ID field to the ID value I want to delete:

    <Batch OnError="Continue">

       <Method ID="1" Cmd="Delete">

           <Field Name='ID'></Field>

       </Method>

    </Batch>

    @Amar: If you are trying to set a default value using the exact steps documented in this blog post, then it won't work. Go through the comments in this post (yes, I know there are a lot) and you will see other ways to design the form template and this is what you will need to do.

    @Dushi: I just tested the following:

    https://MyTestSite/sites/Test/subsite1/subsite2/subsite3/subsite4/subsite5/subsite6/lists/MyList

    https://MyTestSite/sites/Test/subsite1/subsite2/subsite3/subsite4/subsite5/subsite6/_vti_bin/lists.asmx

    Scott

  • DushiPunda says:

    Scott,

    Thank you so much for the reply. I think I figured out what I was doing wrong the first time. It appears the fields in my list get a very strange name, for example:

    "Full_x0020_Name"

    "Rate_x002f_Rank"

    "Date_x0020_Completed"

    I had to adjust accordingly in my CAML and now it works.

    Now, for me, I deleted the first repeating table (i.e. the table that shows all of the data that is already in the list. That leaves me with one repeating table, which is the table with the list field names on the left (derived from the CAML) and the user input for those fields on the right. One question I have now is:

    The fields on the left display the exact names from the CAML, is there any way to change that? I tried messing with the CAML a bit, but wasn't able to figure much of anything out.

    I have a few more questions:

    1. The CAML is local to my computer. If I send this to someone on the other side of the world or even, to someone on the other side of the room, is it still going to work?
    2. Similarly, if I open this in InfoPath Filler (vice Designer), it tells me that the forms template is on my local computer – how do I change it so the template is on a centralized location (i.e. the sharepoint)? Should I just upload the template to my sharepoint and then open that template file with Filler and save it as the .XML?

    I think that may be all of the questions I have. Thank you so much again for replying.

    -Dushi

  • Scott Heim says:

    Hi DushiPunda,

    I am glad you were able to get the process working. Regarding the "strange name" scenario, this is expected from SharePoint as it has to encode certain characters. As an example, "_x0020" is an encoded space.

    Regarding your additional questions:

    1) The CAML is local to my computer. If I send this to someone on the other side of the world or even, to someone on the other side of the room, is it still going to work?

    > When you follow the steps in this post, that CAML file is embedded as a "Resource file" in the XSN. (You can see this by opening the XSN in Design View, selecting the Data tab and then clicking "Resource files" in the Ribbon.) So yes – when you publish or send this XSN to other users, the CAML file goes with the XSN.

    2) Similarly, if I open this in InfoPath Filler (vice Designer), it tells me that the forms template is on my local computer – how do I change it so the template is on a centralized location (i.e. the sharepoint)? Should I just upload the template to my sharepoint and then open that template file with Filler and save it as the .XML?

    > No – you need to "publish" the XSN to your SharePoint site. See this link for more information:

    support.office.com/…/Publish-a-form-bd6eb030-b26b-4774-b22b-7c80e0089403

    Scott

  • dmawer says:

    Hi Scott,

    A great article, am I assuming that you can use the same technique to update/delete from the list too, I appreciate that I'd need some more CAML xml queries.

    Is this possible without code and I would like to do this in IP2010 and MOSS 2007.

    I have followed your article with success 🙂

    Regards,

  • John Marno says:

    Hello, we are working in SP 2013 now – and trying to implement a variation of this technique for submitting to a SP list via Web Service. The difference is that we have a Parent-Child(ren) or Header-Detail relationship and we want to use the technique here to submit to the Child list. It all seems to go smoothly until we actually click 'Save <Detail Entity>' and we get the dreaded 5567 error and off I go to the Error Logs. There I find a 500 error. So it looks as if I am able to hit the service but then am having issues.

    Before I elaborate, let me know if anyone is listening and able or willing to help…thx.

  • Hadden says:

    Dmawer,

    Change the cmd="New" to cmd="update" you will need to carry the ID with you as well as the other fields.

    John Marno,

    I am having the same error, but only when i try to use the method on a Browser form.  No issues with the client form.

    Does anyone know a trick to get it to work on the browser forms?

  • nedaJav says:

    Hi I get this error. Any Body Know why?

    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 using the form. For more information, contact the site administrator.

    An entry has been added to the Windows event log of the server.

    Log ID:5567

  • nedaJav says:

    Hi I get This error on submit the form.Any Body Know why?

    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 using the form. For more information, contact the site administrator.

    An entry has been added to the Windows event log of the server.

    Log ID:5567

  • Kamalpreet Singh says:

    When I submit from InfoPath filler then it work like charm but after publishing on SharePoint if I try to submit then it says "Sending data to the server… "

    but nothing happens after this..

  • Guy Boswell says:

    Same as Kamalpreet Singh, I copied this and it works a charm in filler but throws error in browser.

    I am using IP2010, SP2013 implemented in cloud so no access to error logs.

    Anyone got any ideas?

  • Spassler says:

    My question would be, once you fill out the form and submit it, and repeating data is sent to the list can you update the "form" and hit submit again without having it create duplicate items?

  • Scott Heim says:

    @Kamalpreet and @Guy: if you are trying to use this in an Office 365/SharePoint Online site, it will not work as InfoPath is unable to call the necessary SharePoint web services from a browser form. This is due to the security needs in O365 and the fact we are unable to disable the Loopback check.

    @Spassler: If you simply use the same "Add list item template" to submit the data again, it will be added again. You will have to implement logic to "update" those that already exist and "add" those that are new.

    Scott

  • Maria says:

    I followed the steps except for adding the Submit web service in lists.asmx, I don't see how to add this in lists.asmx, after hitting Submit button, message is  "The form is successfully submitted", however my SharePoint list doesn't have the data that I have entered in my Template form.  Should I let our web group to add the Submit in the lists.asmx?

    Please help

  • Scott Heim says:

    Hi Maria,

    You don't add the submit web service connection "in" lists but you add it in your InfoPath Form Template "to" the lists.asmx web service. Take a look at the steps again and keep in mind, you need to add this to the lists.asmx web service at the same level your list resides. So as an example:

    – If your list location is like this:

    http://YourSharePointSite/Lists/MyList

    Then the URL for the lists web service would be:

    http://YourSharePointSite/_vti_bin/lists.asmx

    – If your list location is like this:

    http://YourSharePointSite/YourSubsite/Lists/MyList

    Then the URL for the lists web service would be:

    http://YourSharePointSite/YourSubsite/_vti_bin/lists.asmx

    – If your list location is like this:

    http://YourSharePointSite/sites/SomeSite/Lists/MyList

    Then the URL for the lists web service would be:

    http://YourSharePointSite/sites/SomeSite/_vti_bin/lists.asmx

    NOTE: It is important to know the process documented in this blog post will not work with Office 365 – this will only work with your On Premise SharePoint server.

    Scott

  • Shawn Connelly says:

    Same issue as the rest. When I submit, I don't see any error messages, but the new list item is never added.

  • Matt says:

    I was able to use this method to submit data to a list, I did run into one problem though. I cannot use a multiple line textbox with this method. Any time I attempt to make the textbox multiple lines it changes to be read-only. Does anyone know a way around this so the form can use a multiple line textbox?

  • tweaker says:

    New to Infopath.  This article is still solid and relevant

  • geordie tom says:

    All, I found a way (at last) to populate the Batch CAML Fields via rules rather than having to type them in! After dragging the Batch connection onto your form, add rules to e.g. a button to update the Batch/Method/Field value.

    When you run the form the rule populates ALL the Fields, BUT if you publish as source files, find the rule in the manifest (this one updates the Field to 99) : e.g.<xsf:assignmentAction targetField="xdXDocument:GetDOM("caml")/Batch/Method/Field" expression=""99""></xsf:assignmentAction>

    and add a filter to the Field:      Field[@Name="ID"]

    Save and design the Manifest file in IP and the rule now works.  Do the same for the other rules, targeting the correct Name.

  • geordie tom says:

    Further to my last post, the Field filter I posted had &quots which show as quotation marks in my post.  The filter needs to be

    Field[@Name=&qu0t;ID& qu0t;], (I've substituted 0s rather than Os here so it doesn't get shown as " again.)

    Hope that isn't too confusing.

    BTW my solution was for updating an O365 list item.

  • AAH says:

    Scott,

    Thank you for this information.  I hope that it will work for me.

  • AAH says:

    Hi,

    Instead of adding to a list, I would like to update and existing record in the list.

    On the InfoPath form, I have a drop down list with ID's.  The user select the record to update, by selecting the ID.  In the InfoPath form I need to pass the ID to the XML.  I created a rule that set the ID field's value with the ID selected from the drop down list.  Is this correct? What am I missing? Your help is appreciated.

    I followed the steps and I get the "Submit is successful" message.  But the record is not updated.  I do not think I am passing the ID correctly.

    My XML is the following:

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

    <Batch OnError="Continue">

       <Method ID="1" Cmd="Update">

           <Field Name="ID"></Field>

           <Field Name="FirstName"></Field>

           <Field Name="LastName"></Field>

           <Field Name="Address1"></Field>

           <Field Name="Address2"></Field>

           <Field Name="City"></Field>

           <Field Name="State"></Field>

           <Field Name="PostalCode"></Field>

           <Field Name="Country"></Field>

           <Field Name="HomePhone"></Field>

           <Field Name="CellPhone"></Field>

           <Field Name="WorkPHone"></Field>

           <Field Name="Fax"></Field>

           <Field Name="DOB"></Field>

           <Field Name="SocialSecurityNumber"></Field>

           <Field Name="DriversLicenseNumber"></Field>

           <Field Name="LicensePlateNumber"></Field>

           <Field Name="VehicleMake"></Field>

           <Field Name="VehicleModel&qu