Accessing values in the form using code - InfoPath Dev
in

InfoPath Dev

Accessing values in the form using code

Last post 04-20-2011 05:00 AM by Skarn. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-15-2011 03:09 AM

    • tr1976
    • Not Ranked
    • Joined on 04-13-2011
    • Posts 1

    Accessing values in the form using code

    Hi, I'm completely new to Infopath so I might be on the wrong track altogether, but I'm trying to read fields within a repeating group and I'm not sure what the correct method should be.

    I have a simple form with an engineer  name, followed by a repeating group of 2 fields, CustName and Miles.

     I'm trying to loop through each item in this group and read the values. I'm sure its simple when you know how, but I've been trying various combinations of properties for XPathNavigator and XPathNodeIterator without success. I can read the engineer name just fine.

     Here is a dump of the output from the form. Can anyone help? I'm using VB.Net

    <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-04-11T09:34:15" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
        <my:Engineer>Mr Smith</my:Engineer>
        <my:entries>
            <my:CustName>Somewhere</my:CustName>
            <my:Miles>12</my:Miles>
        </my:entries>
    <my:entries>
                                        <my:CustName>Somewhere else</my:CustName>
                                        <my:Miles>20</my:Miles>
                                    </my:entries></my:myFields>

    Thanks

  • 04-17-2011 09:32 AM In reply to

    Re: Accessing values in the form using code

    What are you attempting to do with the values?  Perhaps it can be done without code.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-20-2011 05:00 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: Accessing values in the form using code

    I can't do this in C, but I can in jScript/vbScript...

    So in case you can use this method. JScript.

    var strCustName;
    var nodesToIterate = XDocument.DOM.selectNodes("//my:entries");
    for(i=0;i<nodesToIterate.length;i++)
    {
         strCustName = nodesToIterate(i).selectSingleNode("./my:CustName").text;
         XDocument.UI.Alert(strCustName);
    }

     

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