INSERT mult fields in repeat sec using SP - InfoPath Dev
in

InfoPath Dev

INSERT mult fields in repeat sec using SP

Last post 07-21-2006 06:15 AM by BonsaiGuy. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-17-2006 06:51 AM

    INSERT mult fields in repeat sec using SP

    Hi Everyone,

    I hope I can make my question as clear as possible, I think it is newbie ignorance but here it goes.

    - I have a repeating section with multiple fields on it.
    - for example let's say one of those fields is a text box called 'happyfield'
    - using Microsoft's .NET plug-in I have been sucessfully using insert stored procedures.
    - In the code behind to get a value of a field I want to insert into the DB I use something like 'FootnoteLabel = thisXDocument.DOM.selectSingleNode("//my:myFields/my:sec_QuestionnaireForm/my:sec_AddSelection/my:sec_FootnoteAdd/my:txt_FootnoteLabel").text'

    If the user creates 6 'happyfield's, how do I know what to specify for the field name. If I use my:happyfield.text that would not know about the other 5. If there some kind of FOR EACH parameter I can pass it so it will loop through and I can run the INSERT SP for each rown in the repeating section?

    Thank you in advance I really appreciate it!



  • 07-18-2006 09:01 AM In reply to

    Re: INSERT mult fields in repeat sec using SP

    Yes, there is. This is is how I do it:

    IXMLDOMNodeList nlHappyFields = thisXDocument.DOM.selectNodes( "//my:myFields/my:group1/my:group2/my:happyfield" );
    IXMLDOMNode nHappy;

    while( (nHappy = nlHappyFields.nextNode()) != null )
    {
    thisXDocument.UI.Alert( "State of happiness: " + nHappy.text );
    }


    I hope this helps! For XPath tutorial, this one is great:http://www.w3schools.com/xpath/default.asp

    You could also do something like this:

    thisXDocument.DOM.selectNodes( "//my:myFields/my:group1/my:group2/my:happyfield[0]" );
    thisXDocument.DOM.selectNodes( "//my:myFields/my:group1/my:group2/my:happyfield[1]" );
    thisXDocument.DOM.selectNodes( "//my:myFields/my:group1/my:group2/my:happyfield[2]" );
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-18-2006 12:30 PM In reply to

    Re: INSERT mult fields in repeat sec using SP

    I can't wait to give this a shot.

    Thank you for your help Matt!
    This has been a big stop point for me in my project.

  • 07-21-2006 06:13 AM In reply to

    Re: INSERT mult fields in repeat sec using SP

    Hi Matt, Just wanted to let you know that this worked out great and I appreciate the help. Using VB.NET as the background scripting language only the syntax changed a little since there was no IXMLDOMNode or IXMLDOMNodeList available to select from. This is what I did (which is almost identical)

    DIM HappyFields As DOMNodeList
    DIM HappyField As DOMNode

    HappyFields = thisXDocument.DOM.selectNodes("//my:myFields/my:blahblah1/my:happyfield")
    HappyField = HappyFields.nextNode()

    For cnt As Integer = 0 To HappyFields.length - 1
    thisXDocument.UI.Alert(HappyField.text)
    HappyField = HappyFields.nextNode()
    Next

    Thanks again, Bonsai
  • 07-21-2006 06:15 AM In reply to

    Re: INSERT mult fields in repeat sec using SP

    obviously there are a lot of varations one could use on this as well.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.