Converting vb code from infopath 2007 to 2003 - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Converting vb code from infopath 2007 to 2003

Last post 02-17-2010 05:22 PM by me789. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-11-2010 09:32 AM

    • me789
    • Not Ranked
    • Joined on 02-09-2010
    • Posts 3

    Converting vb code from infopath 2007 to 2003

    Hello,

    I have written several form projects using infopath 2007 and have been able to find enough code examples to wrap my head around the coding and make my way through xml files. However on this project several of the main users of the form refuse to upgrade to office 2007 so i'm stuck with creating this form compatible with 2003 and i cant find many examples using vb. Right now I have several forms, one for each department pertaining to there specific tasks to complete a single job, and status info and such from each of these forms is referenced on one overview form. I want to be able to push one button on the overview form and using a CAML file and the updatelistitem method, set a completed flag in sharepoint for each of the referenced forms so they can all be filtered out of view. I have the basics  working in 2007 but cant seem figure it out for the 2003  object model. I'm hoping someone could give me some 2003 code examples similar to this or show me what this would look like.

    Sample

     Public Sub close_out()

    Dim domNav As XPathNavigator = MainDataSource.CreateNavigator()

    Dim itemNav As XPathNodeIterator = domNav.Select("/my:myFields/my:fe_hide/my:fe_request", NamespaceManager)

    Dim cfile As XPathNavigator = DataSources("shippedxml").CreateNavigator()

    While itemNav.MoveNext()

    cfile.SelectSingleNode("/Batch/Method/Field [@Name = 'ID']", NamespaceManager).SetValue(itemNav.Current.SelectSingleNode("my:frowid", NamespaceManager).Value)

    DataConnections("shippings").Execute()

    End While

    End Sub

     

    Filed under:
  • 02-17-2010 10:42 AM In reply to

    • me789
    • Not Ranked
    • Joined on 02-09-2010
    • Posts 3

    Re: Converting vb code from infopath 2007 to 2003

    I have been reading up on this and i have some of it working with the code below code. One of the two issues i'm still having is while looping through the repeating table "/my:fe_request" i can not get the value  of the node ""/my:fe_request/my:frowid" and copy it to the variable aa. The other thing i'm not sure about is how to submit the CAML file once it is set up. i have tried several variations on the submit code below, but non have worked so far.

    I appreciate any help you can give.

    Public Sub test1()

    Dim xmldata

    Dim count As Integer

    Dim aa As String

    Dim xmlnodelist As IXMLDOMNodeList = thisXDocument.DOM.selectNodes("/my:myFields/my:fe_hide/my:fe_request")

    xmldata = thisXDocument.GetDOM("shippedxml").selectSingleNode("/Batch/Method/Field[@Name='ID']")

    If (xmlnodelist.length > 0) Then

    For count = 1 To xmlnodelist.length

    Try

    aa = xmlnodelist(count).selectSingleNode("frowid").text

    xmldata.text = aa

    Catch

    End Try

    XDocument.DataAdapters("shippingsubmit").submit

    Next

    End If

    End Sub

  • 02-17-2010 03:38 PM In reply to

    Re: Converting vb code from infopath 2007 to 2003

     You're missing a my: from your frowid line, but since the xmldata variable is referencing a single node, your code is set up to place new values into that field every time the loop iterates until the value from the last loop is placed there and the loop ends.  Is this what you mean to do?  The data source where you're assigning the values seems to be different from the one you're submitting.

     For the submit code, you should be using thisXDocument, not XDocument, and Submit() should be capitalized.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-17-2010 05:22 PM In reply to

    • me789
    • Not Ranked
    • Joined on 02-09-2010
    • Posts 3

    Re: Converting vb code from infopath 2007 to 2003

    Thank you for your help.

     I now have it set up like below, but I now get a "NullReferenceException was unhandled by your code. Object reference not set to an instance of an object" error pop up when the line "test_var = xmlnodelist(count).selectSingleNode("my:frowid").text" is executed. All it should be doing is getting a value from a node located within a repeating section and placing it in a variable of type string.

    I put a watch on "xmlnodelist(count).selectSingleNode("my:frowid").text"   and the value i'm looking for is displayed in the watch window, but I still get the error. Would you or anyone else know why this would be happening.

    'check if there is at least one repeating section

    If (xmlnodelist.length > 0) Then

    'loop through repeating section

    For count = 1 To xmlnodelist.length

    'at each node of repeating sec, get value from "/my:myFields/my:fe_hide/my:fe_request/my:frowid" and place it in a variable

    test_var = xmlnodelist(count).selectSingleNode("my:frowid").text

     

    'update CAML file with value

    xmldata.text = test_var

    'submit CAML file using submit data connection to sharepoint document librairy

    thisXDocument.DataAdapters("shippingsubmit").Submit()

    Next

    End If

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