Setting a Text Field Based on a Secondary Data Source Drop Down Li

D

Dan The Man

Hi All,

I've been having some difficulty setting a text field using a secondary data
source.

Here is the situation:
- I have a repeating section that contains to fields of type string.
- The first field (called "PersonsName") is a drop down list tied to a
secondary datasource (called "People").
- Data Source "People" contains the following dataFields:
@Name
@Age

- What I would like to see happen is when the user selects a persons name
in the first field "PersonsName", I want the second field (called
"PersonsAge"), a text field, to be set to the corresponding Age of that
person from the Datasource.

Details:

What I have done to date that hasn't worked:
1) Tried to create a rule attached to the "PersonsName" field that set
the "PersonsAge" field to:

xdXDocument:GetDOM("People")/dfs:myFields/dfs:dataFields/dfs:people[@Name =
..]/@Age

or to:

xdXDocument:GetDOM("People")/dfs:myFields/dfs:dataFields/dfs:people/@Age[@Name = .]

or to:

xdXDocument:GetDOM("People")/dfs:myFields/dfs:dataFields/dfs:people/@Age[xdXDocument:GetDOM("People")/dfs:myFields/dfs:dataFields/dfs:people/@Name = .]

2) I've converted the "PersonsAge" text field to a drop down list that
sourced the secondary data source but was filtered on the PersonsName. This
worked but I couldn't get the drop down to select the first non blank entry
in the list.

Now, I don't know why I haven't been successful in getting the value from
the datasource. I'm sure it is something simple.

Any help would be appreciated.

Thanks
 
D

Dan The Man

Let me add that I could create a solution in C# managed code but would rather
find a solution through rules if at all possible.
 
A

aturner

I'm having a similar problem. I followed the instructions in the sample
below, but it is not pulling the appropriate data from the XML data source;
it seems that the filter is not working. Instead of checking for matching
entries (i.e., does selection match the corresponding selection in the XML
source), it fills in the field with data from the first record in the XML
data source every time. Any ideas?
 
M

Matthew Blain \(Serriform\)

If it's within a repeating section, you may need to edit the XPath filter by
hand to make sure that it's using the current node. You can also use a rule
instead of a default value (very similar technique). You can also use
script/code if necessary (off the top of my head it may be for repeating
sections), I believe that there's an example on infopathdev.com.

--Matthew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top