Fill a queryField from another file - InfoPath Dev
in

InfoPath Dev

Fill a queryField from another file

Last post 05-28-2006 11:07 PM by gregv. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-24-2006 06:35 AM

    • gregv
    • Not Ranked
    • Joined on 05-24-2006
    • France
    • Posts 14

    Fill a queryField from another file

    Hello
    I've got an extensible table wich has on each line a button.
    This button has to open another infopath file and make a query depending on the line it was activated.
    The files are both linked to a SQLserver database. Here is the code put on the button :
    function CTRL63_7::OnClick(eventObj)
    {
    var n1 = null;
    n1 = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:co_refdevis/@do_id");

    var xd = null;
    xd = Application.XDocuments.NewFromSolution("V:\\...\\FileToOpen.xsn");

    var n2 = null;
    n2 = xd.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:co_dossiers/@do_id");

    n2.text = n1.text;
    xd.Query();
    }

    When I click on a button, it opens the file correctly but throws an error (translated from french) : Reference to non-declared prefix space : dfs
    In debug, the error occurs on the line n2 = xd.DOM.selectSingleNode(...);

    I don't understand because the two files are both based on SQLserver and dfs appears in both when i use formula.
    Do someone knows what causes this error please ?

    Thanks in advance.
  • 05-24-2006 08:24 AM In reply to

    Re: Fill a queryField from another file

    You will have to tell the node about the namespace that you are using, try this immediatly after NewFromSolution():

    xd.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' );
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-24-2006 08:36 AM In reply to

    • gregv
    • Not Ranked
    • Joined on 05-24-2006
    • France
    • Posts 14

    Re: Fill a queryField from another file

    Thanks, it works.
    But I found another problem, the value contained in n1.text is always the same, even if I click on different lines. Do I have to specify something else in the first selectSingleNode to precise to use the current line ?
  • 05-24-2006 10:06 PM In reply to

    Re: Fill a queryField from another file

    Hi gregv,
    On the click of a button(in a row ) of a repeating table, if u need to access the value of a control in the same row, then u need to use
    n1=eventObj.Source.selectSingleNode("<Field name>");

    Note that <FieldName> is not the whole XPath of that field,but just the particular field's name only.

    Just check out the following link
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1986&SearchTerms=e.Source

    Regards,
    Abhishek
  • 05-28-2006 11:07 PM In reply to

    • gregv
    • Not Ranked
    • Joined on 05-24-2006
    • France
    • Posts 14

    Re: Fill a queryField from another file

    Sorry for my late answer but I was on hollidays for 4 days.
    So I tried this morning your solution Abhishek and it works.
    Thank you for your help :)
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.