14

I have a infopath form created from a sharepoint list content type. In this form I need to add a repeatable table to send data to another sharepoint list. So when people submit this form the original list on which the form is based will be updated as also the second list. How can I submit data to this second sharepoint list?

I have already created a WCF webservice which can add items to a list but it does not work with infopath.

Can anybody show me some instructions on how to build or use a webservice that allows me to submit fields to a sharepoint list and then use it in infopath 2010?

Thanks

4 Answers 4

6

Concerning the answer with reference to

I managed to succeed in running the code from that article in Infopath 2010 (Sharepoint Online/Office 365) only after I changed CAML template XML file content from given in article:

<?xml version="1.0" encoding="UTF-8" ?>
<Batch>
  <Method ID="1" Cmd="New">
    <Field Name="Title" />
  </Method>
  <Method ID="2" Cmd="New">
    <Field Name="Title" />
  </Method>
</Batch>

to

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

Until this change, I was getting

  • {"InfoPath cannot submit the form.\nAn error occurred while the form was being submitted.\n\nThe SOAP response indicates that an error occurred on the server:\n\nException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.\rhttp://schemas.microsoft.com/sharepoint/soap/\">Value does not fall within the expected range.\n"}

Also that article fails to mention to create repeating table from secondary data source (2007) or secondary data connection (2010)

to create repeating table from secondary source

This particular article exemplifies how to submit multiple items to a list.

Generally speaking, any submit to a web service data connection uses CAML XML template and filling repeating table...

Following

with some obvious modifications, it is possible to submit to more than one list from one Infopath form.

2

Here is a way to do it directly in InfoPath, http://blogs.msdn.com/b/infopath/archive/2006/04/05/569338.aspx. It's called the double eval trick and can be used to turn repeating form data into a single column value that can be pushed to a Sharepoint list (multiple line of text column).

You could push this to a Holding list where you could then use an event receiver to take that multiple line of text data, parse it out and update items in the desired list.

2

http://www.bizsupportonline.net/infopath2007/how-to-submit-items-rows-repeating-table-infopath-sharepoint-list.htm

There is a step by step process to do it above.

The solution is described as:

Programmatically add rows of data from a Repeating Table to a SharePoint list by submitting a CAML update batch to the UpdateListItems method of the Lists web service that comes with Windows SharePoint Services (WSS).

requirements: Sharepoint Designer, Infopath

6
  • The question asks how to built a webservice and your answer references the metod how to use ready, built-in sharepoint web service Lists.asmx Commented Aug 24, 2012 at 8:48
  • yes this prebuilt web service contains an UpdateListItems web method which you can use to accomplish what he is trying to do. If you wanted to build your own web service, you could copy _vti_bin/Lists.asmx and modify it and add or remove any additional features you want.
    – fa1c0n3r
    Commented Aug 24, 2012 at 9:00
  • Can't do it. I am on Sharepoint online (Office 365) where custom web service cannot be deployed, by design (and security considerations). Besides, the phylosopy of sharepoint is to use built-in functionality but not to meddle with your own. Though, my point is that you answered something that was not asked Commented Aug 24, 2012 at 9:12
  • :) design or misdesign
    – fa1c0n3r
    Commented Aug 24, 2012 at 9:18
  • +1 interesting, though though all my attemts to follow your reference directly failed. Added my follow-up on your answer Commented Aug 27, 2012 at 6:57
0

I have no idea how to submit repeating table data to SharePoint list using WCF service but you can submit the data contained in repeatable table of InfoPath using SharePoint Object Model. I have done this using SharePoint Object Model and it is working absolutely fine.

The below code was written to submit details of Victim's Basic Information like Name, DOB, CaseNumber, Nationality, etc.. to a SharePoint Custom List.

This is the actual code I have used in my project but you can edit in the way you want.. :)

Pls let me know if you have any queries.

using Microsoft.Office.InfoPath;
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Text;

using Microsoft.SharePoint;
using System.Security.Principal;
using Microsoft.SharePoint.Utilities;

namespace CMSForm
{
public partial class FormCode
{
 private const string REQUEST_MODE_CONTROL = "/my:myFields/my:DeveloperSection/my:RequestMode";

 private const string CASENUMBER = "/my:myFields/my:CaseNumber";

    public void InternalStartup()
    {
        ((ButtonEvent)EventManager.ControlEvents["btnSubmit"]).Clicked += new ClickedEventHandler(btnSubmit_Clicked);
    }

    public void btnSubmit_Clicked(object sender, ClickedEventArgs e)
    {
        try
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                _RequestMode = _root.SelectSingleNode(REQUEST_MODE_CONTROL, this.NamespaceManager).Value.Trim();

                WriteLog("_RequestMode     :" + _RequestMode);
                if (!string.IsNullOrEmpty(_root.SelectSingleNode(CASENUMBER, this.NamespaceManager).Value))
                {
                    _caseNumber = Convert.ToInt32(_root.SelectSingleNode(CASENUMBER, this.NamespaceManager).Value);
                    submitVictimBasicInformation();

                    DataConnections["CaseSubmit"].Execute();

                    // uploadAttachmentInDocLib();
                }
            });
        }
        catch (Exception ex)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                HandleException(ex);
            });
        }
    }

    private void submitVictimBasicInformation()
    {
        try
        {
            SPSite site = SPContext.Current.Site;//new SPSite("http://pro1/sites/cms/");
            using (SPWeb spWeb = site.OpenWeb())
            {
                spWeb.AllowUnsafeUpdates = true;

                //WriteLog("submitVictimBasicInformation     : Start");
                //SPList victimBasicInfoList = VictimBasicInformationList;
                SPList victimBasicInfoList = spWeb.Lists["VictimBasicInformationList"];

                SPListItemCollection oldListItemColl;
                oldListItemColl = getSPListItemCollection(_caseNumber, victimBasicInfoList);
                List<int> lstID = getSPListItemIDs(oldListItemColl);

                XPathNodeIterator rows = _root.Select("/my:myFields/my:group7/my:VictimsInformationRepeating", NamespaceManager);

                while (rows.MoveNext())
                {
                    SPListItem objListItem = victimBasicInfoList.Items.Add();
                    objListItem["CaseNumber"] = _caseNumber;
                    objListItem["Name"] = rows.Current.SelectSingleNode("my:VictimsName", this.NamespaceManager).Value;


                    if (!string.IsNullOrEmpty(rows.Current.SelectSingleNode("my:VictimsDOB", this.NamespaceManager).Value))
                        objListItem["DateOfBirth"] = Convert.ToDateTime(rows.Current.SelectSingleNode("my:VictimsDOB", this.NamespaceManager).Value).Date;

                    objListItem["Sex"] = rows.Current.SelectSingleNode("my:Sex", this.NamespaceManager).Value;

                    objListItem["Nationality"] = rows.Current.SelectSingleNode("my:VNationality", this.NamespaceManager).Value;
                    objListItem["IdentificationType"] = rows.Current.SelectSingleNode("my:VIDType", this.NamespaceManager).Value;
                    objListItem["VictimID"] = rows.Current.SelectSingleNode("my:VictimID", this.NamespaceManager).Value;
                    objListItem["ContactInformation"] = rows.Current.SelectSingleNode("my:VContactInfo", this.NamespaceManager).Value;
                    objListItem["EmailID"] = rows.Current.SelectSingleNode("my:VEmail", this.NamespaceManager).Value;

                    objListItem["MaritalStatus"] = rows.Current.SelectSingleNode("my:VMaritalStatus", this.NamespaceManager).Value;

                    objListItem["HealthStatus"] = rows.Current.SelectSingleNode("my:VHealthStatus", this.NamespaceManager).Value;

                    objListItem["ProfessionType"] = rows.Current.SelectSingleNode("my:VProfession", this.NamespaceManager).Value;
                    objListItem["EducationType"] = rows.Current.SelectSingleNode("my:VEducation", this.NamespaceManager).Value;
                    objListItem["AccomodationType"] = rows.Current.SelectSingleNode("my:VAccommodationType", this.NamespaceManager).Value;
                    objListItem["AccomodationDetails"] = rows.Current.SelectSingleNode("my:VictimsAccomodationAddress", this.NamespaceManager).Value;

                    objListItem.Update();

                }

                deleteSPListItems(oldListItemColl, lstID);

                spWeb.AllowUnsafeUpdates = false;
            }

            //WriteLog("submitVictimBasicInformation  : END");
        }
        catch
        {
            throw;
        }
    }
}

}

Thanks & Best Regards,

Hope this helps you to some extent...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.