Field value determined by external data source - InfoPath Dev
in

InfoPath Dev

Field value determined by external data source

Last post 07-19-2012 02:05 PM by Hilary Stoupa. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-19-2012 12:06 PM

    Field value determined by external data source

    I have created drop down field "STATE" which is populated by an xml data source showing all 50 states, per the following example:

    <items>
    <item>Arizona</item>
    <item>Arkansas</item>
    <item>California</item>
    </items>

     I would like text box field "GL" to display the related numerical IDs based on the selection in "STATE".  For example, If user chooses California in State, GL value is 382.  If user chooses Washingion, GL value is 145.

     I know I could set the value using rules but not sure how to write the formla.  Any ideas?

  • 07-19-2012 12:20 PM In reply to

    Re: Field value determined by external data source

    You could modify your XML file to include the correct number for each state and use a default value for GL. I've attached a simple sample - save it locally and then you right click the file to open in design mode and preview it. Under Data --> Resource Files you can export the XML (if IP 2007, Tools --> Resource Files) so you can see how I set mine up. Right click the text box on the form and select Properties to see the formula I used for the default value.

    Hilary Stoupa

  • 07-19-2012 01:35 PM In reply to

    Re: Field value determined by external data source

    I'm only able to get this to work halfway.  In my form, the formula for field name "GL"  is value[name = State].  This is according to your example.  For some reason, it keeps erroring out because "State" is not a filter in the resource file. 

     External datasource has filgers name and value.  the drop down list works perfectly.  in your example, field1 is not in the resource file so not sure why yours works and mine does not.  Any ideas?

  • 07-19-2012 02:00 PM In reply to

    Re: Field value determined by external data source

    Okay, now I've made a little progress.  I was able to resolve the error by editing the xpath

     xdXDocument:GetDOM("STATES")/items/item/value[xdXDocument:GetDOM("STATES")/items/item/name = xdXDocument:get-DOM()/my:myFields/my:State]

    Now, the only problem is when I select different states, the GL value stays the same.

  • 07-19-2012 02:05 PM In reply to

    Re: Field value determined by external data source

    You want this:

    xdXDocument:GetDOM("STATES")/items/item/value[../name = xdXDocument:get-DOM()/my:myFields/my:State]

     

    Hilary Stoupa

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