Searching for help with techniques to access information within infopath from a listbox. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Searching for help with techniques to access information within infopath from a listbox.

Last post 10-30-2009 12:50 PM by Larry W. Virden. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-30-2009 07:25 AM

    Searching for help with techniques to access information within infopath from a listbox.

    I have an infopath 2007 form (published to sharepoint as a browser viewed form) with 2 views. View 1 is for data entry. The user sees a repeating section containing a listbox. The listbox is populated via a data connection to a sharepoint list containing several columns (country, phone, power) , one of which (country) I use to display in the listbox.

    The second view is formmatted for mailing and the application switches to it just before sending the data being requested. In the second view, I want to display the repeating section data with all 3 columns of values for the country selected.

    Thus, if the user creates 2 sections, and in each section, selects a different country from the listbox, in the Mail view, I want to display section 1 displaying the country, phone and power columns associated with the first country selected, then display section 2 displaying the columns associated with the second country.

    When I get the mail, what I get is:

    country 1
    phone 1
    power 1

    country 2
    phone 1
    power 1

    What technique do I use so that the values from the phone and power information from the 2nd-nth item selected are displayed as expected?

    Right now, the default value is set to the phone or power field from the data connection data source. I looked at trying some sort of filtering, but I don't understand how to use it to indicate that I want the phone column data to come from the current section.  Am I missing something simple?

    Thank you for your help.

    http://wiki.tcl.tk/
  • 10-30-2009 07:51 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    There is a function called current() that gets used in repeating tables to make sure the context of your filter remains with the same row.  InfoPath 2007 automatically puts that in there if you build the rule statement properly.  I have not yet learned the syntax of how to write it on my own, but it clearly writes a different statement when doing filtered values like that in a repeating table.

    If you are going to use multiple sections instead of repeating rows in a repeating table, then you MUST put your repeating table data structure inside another repeating group and use that top-level repeating group to make a repeating section.  That's the only way you can get away with multiple sections referencing the same repeating table.  Once you do that, then ever row in each table of each section will be unique and give unique filtered values for Phone and Power.  I have made a sample, but it won't be fully functional once I remove the data connection to my system.  However, the schema is correct.

  • 10-30-2009 09:16 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

     I'm not sure that's exactly what lvirden was going for.  If I understand correctly, what he wants is to have a separate view where he lists all the items selected in the first view, with details about each item pulled from a secondary data source.  If so, the form I'm attaching is an example of this.

    Clay was certainly right about using the current() function.  The important points about this form are:

    Binding repeating sections in both views to the same repeating section (I think lvirden already has this).
    Using expression boxes that reference the secondary data source, and use the current() function to pick the value that matches the current row.

    This form uses no filtering or default values, and the only rules are on the buttons that toggle between views.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-30-2009 10:34 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    That sounds promising. I'm looking at your attachment, but I'm having a problem figuring out where the current() function is found. When I do a filtering, and I set "view 1 drop down list field name" then "is equal to" and try to insert a formula, I click on field as well as all categories and current() isn't one of the functions.

    http://wiki.tcl.tk/
  • 10-30-2009 10:40 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    I know - I'm saying that InfoPath automatically creates the statement using "current()."  You just have to set it up right in the data schema and then in the default or rule or expression statement that you create by selecting the filter action through the GUI.

    You can see the syntax in my Phone and Power fields.  Double-click them to see the default value statements.  If you click the function button, they will not look right, because I've removed the data connection, but at least you can see how they should look by looking at the default value box of the two fields.

  • 10-30-2009 11:04 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    I'm looking at warrtalon's example. While it isn't exactly what I have, it is similar in concept, I am looking at PhoneIP's property. The value I see is @Phone[@Country = current()/../CountryIP]. I am trying to figure out how this was input through the . insert formula box. when I look in the box, I am seeing:

     GetDOM("RepeatingTest")/dfs:myFields/dfs:dataFields/dfs:RepeatingTest/@Phone[../@Country = current()/../my:CountryIP]

    So what was inserted first - a field/group I presume, and in fact was it the PhoneIP field in group2?

    Did you hand code the other text - because hitting the filter data doesn't show anything in the dialog shown.

     I'm just trying to figure out how to translate what is in this sample with what I need in my application. I've never worked with xpath before, so I'm uncertain what I have to type in and what infopath is going to generate.

     

    http://wiki.tcl.tk/
  • 10-30-2009 11:10 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    Yes, the code in the function box is garble, because I removed the DC.  Don't look at that unless you plan to change your data connection to match mine.

    Instead, just look at the first part in the properties box and remember what it looks like.  You don't have to hand code any of that.  All you do is build the standard filtered value like this:

    - Click the FX button on default value

    - Click Insert field or group

    - Switch to your secondary data connection

    - Choose the Phone node (single-click)

    - Click the filter button

    - Choose the Country node of the secondary data connection on one side

    - Is equal to

    - Choose the CountryIP node of the main data source on the other side

    That's it.  When you do this, IP automatically creates the current() statement that you see in my form.

  • 10-30-2009 11:20 AM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    jimmy, your example was closer to what I was trying to do. Perhaps because of my inexperience with xpath, I'm pretty much stuck at the same place with yours as I am with the other kind gentleman's example - figuring out what I need to type in to get my form to do something similar.

    With your form, I see

    employee[@employeeId = current()]/@name

    where employee is the name of the secondary data source repeating group (in my case from a sharepoint list), employeeid is one of the fields in the group, and name is one of the other fields.

    What I have is this:

    In the infopath form's data source information, I have a group called CountryList, and within it, there is a repeating group called group2. Within it are 3 items, AdapterCountry (the name of view 1's dropdown listbox), PhoneAdapterNumber, PowerAdapterNumber. Within my secondary source (the data connection to sharepoint), I have a repeating group called PhonePowerAdapter, with fields called  :Country, :Power_Adapter, and :Phone_Adapter.

    The control for CountryList is a dropdown listbox inside of a repeating section. This is what I intended to use since I was unable to find a way for a infopath 2007 browser app to support selecting multiple items within a dropdown listbox. 

    So the user creates one or more of these items within the repeating section. When they hit the submit button, a rule kicks off to select a new view. The new view has fields for the country that was selected from the drop down listbox (type listbox), as well as a field for power adapter and a field for phone adapter. These are also in a repeating section.

    My expectation was that since infopath had retrieved the entire sharepoint list when the application started, it was caching, somehow, the ids of the listbox entries that the user selected. So it didn't seem like it was going to be hard to get the values of the other two columns to show up in the appropriate sections of the second view. I mean, the countries are showing up.

    I've tried using 3 listboxes, and just telling them to get the information from the external source and display the appropriate columns. But I couldn't figure out how to get the index information to the listboxes. I tried using text controls and doing a filter to set the field from the secondary source, but I didn't know about the current() function so I didn't know how to get to it. I hoped that IP would just generate it appropriately, but so far that hasn't worked.

    Thank you for your patience with me on this.

     

    http://wiki.tcl.tk/
  • 10-30-2009 12:10 PM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    Thanks - that seems like it worked great. I'll plug it into the code and have some users test it out!

    http://wiki.tcl.tk/
  • 10-30-2009 12:50 PM In reply to

    Re: Searching for help with techniques to access information within infopath from a listbox.

    well, the "smoke test" worked - no data was left smoking. Thank you all so much!

    http://wiki.tcl.tk/
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.