Trouble Updating SP List From InfoPath - InfoPath Dev
in

InfoPath Dev

Trouble Updating SP List From InfoPath

Last post 02-03-2015 12:20 PM by jlarremore. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 02-03-2015 12:20 PM

    Trouble Updating SP List From InfoPath

    I am one step away from getting this to work. I am trying to update a SP 2010 list using InfoPath 2010. My functionality is working except when I submit the data does not update. I am updating in the form code. I have no clue why it is not updating. Any help is appreciated. This is what I based my solution on: http://jaliyaudagedara.blogspot.com/2011/03/submitting-data-to-sharepoint-2010-list.html Here is my code: using Microsoft.Office.InfoPath; using System; using System.Xml; using System.Xml.XPath; using System.Windows.Forms; namespace Sym { 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() { ((ButtonEvent)EventManager.ControlEvents["UpdateBtn"]).Clicked += new ClickedEventHandler(UpdateBtn_Clicked); } public void UpdateBtn_Clicked(object sender, ClickedEventArgs e) { // Write your code here. try { XPathNavigator root = MainDataSource.CreateNavigator(); XPathNavigator myNavigator = this.DataSources["Supplier Routing Receive"].CreateNavigator(); // Retrieve the values for the separation list item string ListName = root.SelectSingleNode("/my:myFields/my:ListName", NamespaceManager).Value;//Setting the GUID string eTitle = myNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title", NamespaceManager).Value; string eVName = myNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Vendor_x0020_Name", NamespaceManager).Value; string eWebPort = myNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Supplier_x0020_Web_x0020_Portal", NamespaceManager).Value; string eEmailDS = myNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Supplier_x0020_Email_x0020_Addre0", NamespaceManager).Value; if ((eWebPort == "Yes") || (eWebPort == "No")) { } else { MessageBox.Show("Supplier Web Portal must be either Yes or No"); } if (ListName == null) { } else { //This is CAML xml file. it contains batch and method nodes XPathNavigator batch = DataSources["Submit"].CreateNavigator(); batch.SelectSingleNode("/Batch/Method/Field[@Name='Title']", NamespaceManager).SetValue(eTitle); batch.SelectSingleNode("/Batch/Method/Field[@Name='Vendor Name']", NamespaceManager).SetValue(eVName); batch.SelectSingleNode("/Batch/Method/Field[@Name='Supplier Web Portal']", NamespaceManager).SetValue(eWebPort); batch.SelectSingleNode("/Batch/Method/Field[@Name='Supplier Email Address for Info Requests']", NamespaceManager).SetValue(eEmailDS); DataConnections["Web Service Submit"].Execute(); // MessageBox.Show(batch.SelectSingleNode("/Batch/Method/Field[@Name='Supplier Email Address for Info Requests']", NamespaceManager).Value.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } }
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.