Default Values and Secondary Datasources - InfoPath Dev
in

InfoPath Dev

Default Values and Secondary Datasources

Last post 08-25-2006 10:05 AM by Greg Collins. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-22-2006 01:30 PM

    Default Values and Secondary Datasources

    I have a field within a secondary datasource that I would like to use as the default value for a field in my form's Main datasource. I used an expression box to verify my query returns the correct results from the secondary datasource. I then copied this query into a TextBox control's default value property, but the data is not populated on startup when I preview the form. Can this be done?

    Thanks,

    Chris
  • 08-22-2006 02:50 PM In reply to

    Re: Default Values and Secondary Datasources

    Hi Chris and welcome to the forums!

    I'm not sure why this isn't working, I've included default values for secondary data sources several times. What kind of secondary data source is it? An XML Document that is included in the form?
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-22-2006 04:20 PM In reply to

    Re: Default Values and Secondary Datasources

    Secondary data sources, by their nature, contain their default values within them. For example, if you have a 2DS connected to an XML file, that XML file contains all the default values... these are not set at runtime unless you use rules or code.
  • 08-22-2006 06:42 PM In reply to

    Re: Default Values and Secondary Datasources

    It's an XML file included as a resource file in the template. Here is an snippet of the 2DS (nice acronym) instance:


    <Line>
    <LineID>Line 1</LineID>
    <Component>
    <PartNumber>12345</PartNumber>
    <Default>true</Default>
    </Component>
    <Component>
    <PartNumber>abcdef</PartNumber>
    <Default>false</Default>
    </Component>
    </Line>


    There can be multiple <Line /> elements within the 2DS and each one corresponds one to one with a <Line /> element in the main data source. The two schemas are identical with the one difference being that the main data source schema allows only one <Component /> element per <Line />.

    For each <Line /> element in the main data source, I am trying to set the <PartNumber /> grandchild to a value from the 2DS on form startup. I verified my xpath by placing an expression box next to the textbox control bound to the <PartNumber /> element. The textbox control's default value uses the same expression as the expression box. The expression box returns the correct data but the textbox remains blank.

    Thanks,

    Chris
  • 08-23-2006 09:29 AM In reply to

    Re: Default Values and Secondary Datasources

    Okay... Going with the assumption that you have a 2DS (Note this needs to be added as a "Data Connection" and not just a "Resource") as described above, with a root node being <Lines>, and also that your main data source is of a similar structure, only that it can have a single Component...

    Let's say you add a repeating table to your view based on the main dom repeating Line node. That table has two columns. Col1 is a drop-down for LineID and Col2 is a drop-down for Component.

    1. Right-click Col1 drop-down and choose Properties.
    2. Select "Look up values in a data connection..."
    3. Select the Lines data connection.
    4. Select /Lines/Line/LineID as the entries.
    5. Click OK.

    Now the Col2 drop-down is set up this way:

    1. Right-click Col1 drop-down and choose Properties.
    2. Select "Look up values in a data connection..."
    3. Select the Lines data connection.
    4. Select /Lines/Line/Component as the entries--AND set a filter.
    5. Click Fitler Data, and then click Add.
    6. Select PartNumber in the first list.
    7. Select Use Formula in the 3rd list and type: current()/my:LineID
    8. Click OK 5 times to go back to the view.

    Now Preview.
    The first drop-down gives you your list of Line IDs. After selecting one of those, your second list gives you a Filtered list of Component Part Numbers based on the selected Line ID.
  • 08-23-2006 10:29 AM In reply to

    Re: Default Values and Secondary Datasources

    Thanks, you understand what I am trying to do. I would prefer to use a textbox control instead of the drop-down list but your solution is acceptable. Out of curiosity, if the drop-down and expression box filters work, why won't the textbox control's defualt value?
  • 08-25-2006 10:05 AM In reply to

    Re: Default Values and Secondary Datasources

    You should be able to use filters on a default value formula for a text box. The example I provided above was just what I built in an attempt to provide the steps in my reply.

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