Getting a reference to datafields in script - InfoPath Dev
in

InfoPath Dev

Getting a reference to datafields in script

Last post 08-22-2006 03:55 PM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-21-2006 02:30 AM

    • henk
    • Not Ranked
    • Joined on 07-26-2006
    • South Africa
    • Posts 4

    Getting a reference to datafields in script

    Hi everyone,
    I'm using a web service to recieve data for my IP form.
    In my script I reference these fields to get values to submit via a SQL stored procedure.
    My problem is, when I go design form --> new from data connection, I can get a reference to these datafields and work with them. However when I go new blank form and then add the data connection afterwards I just can't get a reference. Designing with "new from data connection" would have been fine if it wasn't for the "Query" button that you have to click to get your data on the form.


    This is a short extract of my script (gets a reference to the datafield "ID" and displays the count of records):

    var nodes = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/tns:GetQuestionObjectsResponse/tns:GetQuestionObjectsResult/tns:Question/tns:ID");
    XDocument.UI.Alert(nodes.length);
    eventObj.ReturnStatus = true;

    when using "new from data connection" it displays the correct number, but with "new blank form" and connection added later it is just 0.

    Please if anyone can give me advice I would really appreciate it...
    Thanks!







  • 08-21-2006 11:41 AM In reply to

    Re: Getting a reference to datafields in script

    XDocument.DOM refers to the MAIN data source. When you start with a blank form and add the connection later, you are now working with a SECONDARY data source. You cannot access a secondary data source via XDocument.DOM. Instead you need to use XDocument.GetDOM("Name of Data Source").selectNodes(...);
  • 08-22-2006 12:52 AM In reply to

    • henk
    • Not Ranked
    • Joined on 07-26-2006
    • South Africa
    • Posts 4

    Re: Getting a reference to datafields in script

    Thanks Greg
  • 08-22-2006 03:55 PM In reply to

    Re: Getting a reference to datafields in script

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