Submitting partial form data to multiple web services

A

Andrew Stokes

Hi

I would like to submit parts of my Infopath form data to multiple SharePoint
lists using web services. I would like to specify the site receiving the
data by referencing data in my main data source and I would like to pass part
of the from data to one list (risks) and another set of data in the form to
another list on the same site (deliverables).

I know how to send from data to SharePoint lists through web services but
not how to change the site url based on data contained in the form or how to
send part of the data to one list and part to another.

can anyone help me with this?

Andrew
 
A

Andrew Stokes

I decided to do it with some c#

//set up a web reference called MyWebService

//get the references to the site and lists from the document's data source
XPathNavigator navSiteURL =
navigator.SelectSingleNode("my:BusinessReview/my:project/my:projectSite/my:projectSiteURL", this.NamespaceManager);
XPathNavigator navRisksList =
navigator.SelectSingleNode("my:BusinessReview/my:project/my:projectSite/my:RisksListGUID", this.NamespaceManager);
XPathNavigator navDeliverablesList =
navigator.SelectSingleNode("my:BusinessReview/my:project/my:projectSite/my:DeliverablesListGUID", this.NamespaceManager);

MyWebService.Lists myList = new MyWebService.Lists();
myList.Credentials =
System.Net.CredentialCache.DefaultCredentials;
myList.Url = navSiteURL.ToString() + @"/_vti_bin/lists.asmx";
XmlDocument doc = new XmlDocument();
XmlElement mybatch = doc.CreateElement("Batch");

mybatch .SetAttribute("OnError", "Continue");
mybatch .SetAttribute("ListVersion", "1");
mybatch .SetAttribute("ViewName", "");

//I would replpace the title data with a reference to my
datasource
//and I would add other list fields to be updated
mybatch .InnerXml = "<Method ID='1' Cmd='New'>" +
"<Field Name='ID'>New</Field>" +
"<Field Name='Title'>a nice title for the first
item</Field></Method>";
mybatch .InnerXml += "<Method ID='1' Cmd='New'>" +
"<Field Name='ID'>New</Field>" +
"<Field Name='Title'>another title for the next
item</Field></Method>";

myList.UpdateListItems(navRisksList.ToString(), mybatch);

//do the same for the deliverables
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top