Populate fields based on test to XML resource file - InfoPath Dev
in

InfoPath Dev

Populate fields based on test to XML resource file

Last post 10-12-2005 09:33 AM by Matt Faus. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-12-2005 07:46 AM

    Populate fields based on test to XML resource file

    Basically I have three fields:
    1. Pay #
    2. Date
    3. Settlement Period

    I want to populate the Date and Settlement Period fieds depending on what is entered into the Pay # fields, and I want to get that data from an XML Document (secondary data source - resource file) based on a test of whether the Pay # exist in the XML Doc.

    So here is a snippet of my XML doc.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Dates>
    <Date PayNum="22" Weekending="21/10/05" StlPer="1" />
    <Date PayNum="23" Weekending="04/11/05" StlPer="2" />
    <Date PayNum="24" Weekending="18/11/05" StlPer="1" />
    <Date PayNum="25" Weekending="02/12/05" StlPer="2" />

    </Dates>

    So I want my code to look at what was entered into the Pay # box, chekc and see if that Pay # exist in the XML doc in the PayNum attribute, then populate the Date box with the corresponding Weekending attribute and populate the settlement period box with the corresponding StlPer attribute.

    Thoughts, ideas? I see this as being being some sort of current()test against the PayNum, but I just can't get my head around it.

    Thanks for your continued support.
  • 10-12-2005 09:33 AM In reply to

    Re: Populate fields based on test to XML resource file

    Why don't you implement the onAfterChange() event (on Pay# control) to populate the necessary after the Pay# field has been changed? It would look something like this:

    function msoxd_my_PayNumber::OnAfterChange(eventObj)
    {
    var payNum = Math.parseInteger(eventObj.Site.text);

    var date = secondary_data_source_DOM.selectSingleNode( "\\ns:date[ns:PayNum = " + payNum + "]" );
    var settle = secondary_data_source_DOM.selectSingleNode( "\\ns:date[ns:PayNum = " + payNum + "]" );

    XDocument.DOM.selectSingleNode( "\\my:date" ).text = date;
    XDocument.DOM.selectSingleNode( "\\my:settlementPeriod" ).text = settle;
    }
    How did you create your XML secondary data source? It looks like you have <Date> nodes with several attributes, instead of sub-nodes. Is this correct XML format? If it is, it doesn't seem very effecient. You should structure your XML more like this:

    <Date>
    <PayNum>22</PayNum>
    <Weekending>21/10/05</Weekending>
    <StlPer>1<StlPer>
    </Date>
    Hope this helps....

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.