Solution: Updating infopath Forms/documents in sharepoint via Code - InfoPath Dev
in

InfoPath Dev

Solution: Updating infopath Forms/documents in sharepoint via Code

Last post 06-04-2008 11:00 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-01-2008 11:18 PM

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

    Solution: Updating infopath Forms/documents in sharepoint via Code

    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.

    Question found here: http://www.infopathdev.com/forums/p/7800/28534.aspx#28534

    Solution:

    Details: (Coding-VB Script), Add or update infopath forms/documents in a sharepoint document list.

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

    sSubmitUrl = contains the full url of the infopath document you want to either add or update

    XMLBody = this is the string that contains the complete infopath forms/documents contents, including PI's (Processing Instructions)

    Code:

    Imports System.Net
    Imports System.IO

    Dim sUrl As String = sSubmitUrl
    Dim wResponse As WebRequest = WebRequest.Create(sUrl)
    wResponse.Credentials = CredentialCache.DefaultCredentials

    wResponse.Method = "PUT"
    wResponse.Headers.Add("Translate: f")
    wResponse.ContentLength = XMLBody.Length
    wResponse.ContentType = "text/xml; charset=utf-8"

    'write xml to the request stream.
    Dim sw As New StreamWriter(wResponse.GetRequestStream())
    sw.Write(XMLBody)
    sw.Flush()
    sw.Close()
    Try
    Dim resp As WebResponse = wResponse.GetResponse()
    Catch ex As Exception
    Exit Function
    End Try

  • 06-02-2008 05:40 AM In reply to

    Re: Solution: Updating infopath Forms/documents in sharepoint via Code

    That's a sweet piece of code, thank you!

    I was doing some research in DAVAdapters when this came out. 

     

  • 06-02-2008 07:23 AM In reply to

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

    Re: Solution: Updating infopath Forms/documents in sharepoint via Code

    your welcome.

  • 06-04-2008 11:00 AM In reply to

    Re: Solution: Updating infopath Forms/documents in sharepoint via Code

    Thanks for sharing this!

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