Using XML as a secondary datasource - InfoPath Dev
in

InfoPath Dev

Using XML as a secondary datasource

Last post 11-03-2005 02:22 PM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-24-2005 07:55 AM

    Using XML as a secondary datasource

    Previously I was using cascading WSS lists to contain info that would be used in cascading drop downs in an InfoPath form, but ran into a strange issue where not all available selections were being displayed. I then searched some more and came across Create a Cascading List from a Hierarchical Data Source and after testing this, comverted my multiple lists into one XML document. I have gotten my cascading drop downs populating and filtering correctly, but have 2 questions.

    1) Display "N/A" or "Other" in drop down without having it in the document multiple times

    2) I am trying to get an additional field filled from info taken from the XML document, (note node).

    My Document looks like this

    <?xml version="1.0" encoding="utf-8" ?>
    <Taxonmy>
    <Category Value="Hardware" Note="Some Note Here.">
    <FocusArea Value="Digital Imaging Devices" Note="Another Note here.">
    <FA2 Value="Copiers"/>
    <FA2 Value="Digital Pens"/>
    <FA2 Value="Fax Machines"/>
    <FA2 Value="Image Capture">
    <FA3Value="Digital Camera"/>
    <FA3Value="Web Camera"/>
    </FA2>
    <FA2 Value="Printers"/>
    <FA2 Value="Projectors"/>
    <FA2 Value="Scanners"/>
    </FocusArea>

    What I am trying to get, if it is present, is the NOTE section.
    My Form looks like this
    *Note – All taken from the same Hierarchical Data Source and I am using filters to remove unneeded choices.
    ---------------------------------------------------------
    Category DropDown Note field
    FocusArea DropDown Note Field
    2ndFA Drop Down Note Field
    3rdFA DD Note Field
    4thFA DD Note Field
    ---------------------------------------------------------

    Category and FocusArea will always have a note field, while the others may or may not have one. I tried to code this myself and to use info found herebut was unsuccessful in converting it to vbscript, any Ideas?

    Thanks,
    Mike
  • 10-26-2005 11:56 AM In reply to

    Re: Using XML as a secondary datasource

    If the secondary data source does not have the "N/A" or "Other" in it then you will need to do something like populate the drop-down list via code.

    If you have multiples of that in your XML, then the best choice would be to modify your XML so it only appears once. If that is not possible, then filtering would be the next best choice.

    As for question 2, are you attempting to use rules or code to populate other fields when a selection is made? If not I don't understand your question.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 10-26-2005 12:21 PM In reply to

    Re: Using XML as a secondary datasource

    Greg,

    Thanks for the response. I control the XML file so can do anything I need to it. I tried adding a N/A and an other to each area (from above) but don't really want to go that route as it added close to 70 extra lines to my XML document. Will need to look at populating via code.

    As to question 2. I am not sure which way to go, basically, in my XML document, a node may or may not have a notes field, and if it did have a notes field, I would like to display this in a field that would be next to or underneath the dropdown. The trigger would be based on weather or not the note field is present in the particular node selected.

    Hope this answers your questions. And thanks again for your reply.

    Mike
  • 10-27-2005 09:59 AM In reply to

    Re: Using XML as a secondary datasource

    Whether using rules or code, you should be able to first determine whether the notes node exists. If it does, then you copy it.

    Use conditional formatting on the field in the view. If it is blank, hide it.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
  • 11-02-2005 11:02 AM In reply to

    Re: Using XML as a secondary datasource

    Greg,

    Again, thanks for your help on this, unfortunately I have not been able to get my N/A or other displaying when I use my data source. I have been able to populate the drop down from code but have not been able to get them both into the drop down. Let me back up a little bit and use something that you can see instead of trying to explain everthing. Using the How-To found Here
    let add another selection of bodytype (2-Door or 4-Door) So 1963 would look like:

    <Year value="1963">
    <Make value="Chevrolet">
    <Model value="Corvette">
    <BodyType Value="2-Door"/>
    </Model>
    <Model value="Nova">
    <BodyType Value="2-Door"/>
    <BodyType Value="4-Door"/>
    </Model>
    </Make>
    <Make value="Porsche">
    <Model value="356">
    <BodyType Value="2-Door"/>
    </Model>
    <Model value="Carrera">
    <BodyType Value="2-Door"/>
    </Model>
    </Make>
    </Year>

    So when you select the 1 drop down, you could Choose Chevrolet and the second would only display Corvette or Nova. Select Nova in the third drop down and you choice would be 2 or 4 door.

    Now what I am trying to do is to have the option of choosing either N/A or Other without having to add them to each Year, Make, Model or BodyType entry.

    So, when you make your first choice and the year you want is not listed, you can choose Other, which would then allow a text box to be displayed. Alternativly, if for some reason, the bodystyle was not needed, you could choose N/A when you got to it.

    I have never been the best at explaining things in writing, so I hope that this helps a little bit.

    Thanks again for your time.

    Mike
  • 11-03-2005 02:22 PM In reply to

    Re: Using XML as a secondary datasource

    When populating with code, you must create a list of "<option/>" tags. At the start (or end) of that list, you would have your Other and N/A options. You create them the same way you create the other options coming from your XML file. It shouldn't be difficult to add them to each drop-down list when populating from code.

    Adding more levels to your cascade should be similar to the steps described in the how-to article for cascading lists. Each level past 3 should be similar to how level 3 was added.

    The tricky part is the part is "Other" (unless you have a separate field for them to type into, or an attribute which identifies that they chose "other". Otherwise, once they type a value different from "Other" then conditional formatting will switch back to the drop-down list (which may be what you want). See my free example for ways to make this work.

    I don't know if I helped at all this time or just told you things you already know.

    Greg Collins [InfoPath MVP]
    InfoPath Dev
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.