Solution: Updating custom sharepoint list via Code in Infopath - InfoPath Dev
in

InfoPath Dev

Solution: Updating custom sharepoint list via Code in Infopath

Last post 06-01-2008 11:54 PM by Cutejon. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 06-01-2008 11:54 PM

    • Cutejon
    • Not Ranked
      Male
    • Joined on 03-26-2008
    • Philippines
    • Posts 20

    Solution: Updating custom sharepoint list via Code in Infopath

    Hi Everyone,

    As infopathdev users have been so kind in sharing their thoughts/solutions in the questions I have for Infopath, I would like to share the solution I've found for one of my problems.

    this solution is based on Matt Faus' blog: http://www.infopathdev.com/blogs/matt/archive/2006/02/02/Add-SharePoint-List-Items-with-InfoPath.aspx and you can do the same with the codes found below.

    Solution:

    Details: (Coding-VB Script), Add sharepoint list entries

    Assumptions: Users running this code must have create/edit access to the sharepoint site.

    * Create a web reference in the code with this URL : http://<Main Site>/<Subsite>/_vti_bin/Lists.asmx?WSDL and name it as weblist

    Note: in my experience, placing ?WSDL at the end of the URL is important, without it, the web referrence will point to the main site, not to the subsite, and will not see your list.

    *Your sharepoint list field names can be found under Settings->List Settings,  then under columns click on the column names, then in the URL, look at the value after the "&Field=", this is the field name that sharepoint recognizes.

     *regarding editing lists, you can search for more details on msdn sites.

    Code:

                Dim listService As New WebList.Lists()
                listService.Credentials = System.Net.CredentialCache.DefaultCredentials

                Dim viewstr As String = "{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}"  -> guid of the sharepoint list
                Dim strBatch As String = "<Method ID='1' Cmd='New'>" + _
                "<Field Name='ID'>New</Field>" + _
                "<Field Name='Title'>" + <place your values here>+ "</Field>" + _
                "<Field Name='PName'>" +<place your values here>+ "</Field>" + _
                "<Field Name='Company'>" + <place your values here> + "</Field>" + _
                "<Field Name='Phone'>" + <place your values here>+ "</Field>" + _
                "</Method>"

                Dim xmlDoc As New XmlDocument()

                Dim elBatch As System.Xml.XmlElement = xmlDoc.CreateElement("Batch")
                elBatch.InnerXml = strBatch

                Dim ndReturn As XmlNode = Nothing
                Try
                    ndReturn = listService.UpdateListItems(viewstr, elBatch)
                Catch ex As System.Web.Services.Protocols.SoapException
                    MessageBox.Show(ex.Detail.InnerXml)
                    Exit Sub
                End Try

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.