I have an InfoPath form with custom submit code to update a Sharepoint list by calling the Sharepoint Lists web service. The code runs without any exceptions, and I was able to set breakpoints to make sure that the variables contain the correct values before being sent to the web service. The values never get added to the Sharepoint list, though. Here is my code:
[InfoPathEventHandler(MatchPath = "Submit", EventType = InfoPathEventType.OnClick)]
public void Submit_OnClick(DocActionEvent e)
{
ListsService.Lists listService = new Risk_Form.ListsService.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
string riskID = thisXDocument.DOM.selectSingleNode("//my:myFields/my:RiskID").text;
string headline = thisXDocument.DOM.selectSingleNode("//my:myFields/my:RiskHeadline").text;
XmlDocument doc = new XmlDocument();
XmlElement batch = doc.CreateElement("Batch");
batch.SetAttribute("OnError", "Continue");
batch.SetAttribute("ListVersion", "1");
batch.InnerXml =
"<Method ID='" + riskID + "' Cmd='New'>" +
"<Field Name='RiskID'>" + riskID + "</Field>" +
"<Field Name='Headline'>" + headline + "</Field>" +
"</Method>";
try
{
// Update list using the list's GUID
listService.UpdateListItems("2F6CA5F4-D78A-4716-B111-507917CF89E4", batch);
}
catch(Exception ex)
{
thisXDocument.DOM.selectSingleNode("//my:myFields/my:RiskStatement").text = ex.Message;
}
}