Automatically Update Fields in Repeating Table

U

Uncle Paulie

I have created a new form in Info Path 2003. The first field is a drop list
containing user names. Based on the selection of the name, the next two
fields (User ID and Manager ID) should automatically populate. Each of these
fields has a rule indicating the default value should be the appropriate ID
based on the name selected from the drop list being a match to the secondary
data source where the IDs are stored. This works on the first record. With
the addition of each subsequent record, the User ID and Manager ID fields are
populated with the info for the person selected in the first record, not the
person selected in drop list of the new record. Any ideas how to correct
this?
 
G

Greg Collins

The problem is absolute versus relative XPaths. Because your XPaths are
absolute (meaning they start at some top level node, probably the root node)
and navigate down to the repeating table and fields) they will always get
just the first row.

The rules need to use relative XPaths (i.e. starting at the row or the field
being changed). Creating a rule on the drop-down to populate the other two
fields in the same row show work just fine (i.e. it should create relative
XPaths).

Not sure what you did to get absolute XPaths.
 
U

Uncle Paulie

Thanks for the response Greg. I removed the rules from the ID fields that
were supposed to set the default value based on the selection of the name
from the drop list. I added a rule to the name field drop list to populate
the ID fields based on the selection from the drop list. I'm still getting
the same result. The ID fields continue to be populated with the values from
the first record. I'm a newbie to form design so I'm not really familiar
with the xPath terminology but I'm willing to try any other suggestions you
might have.
 
U

Uncle Paulie

If it helps at all, here is the xPath code from one of the rules I added to
the drop list field:

@LoginID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:CCS_TrainingHistory/@AssociateName = ../@FullName]
 
G

Greg Collins

Something doesn't seem right, but I don't have enough information to go on.

1. Which DOM is the repeating table in?
2. Which DOM are the values stored that are being used in the drop-down?
3. Are the UserID and ManagerID siblings to the UserName in the repeating
table?
 
U

Uncle Paulie

You'll have to forgive me Greg. As I said I'm an InfoPath newbie so I'm in
some uncharted territory here. The form has three data connections. The
first is the main connection - the SQL table where the student training
history is stored. The second is the table where the course information is
stored. The third is the student database where all of the student info is
stored. Upon creating a new form and establishing the Data Connections, I
draggeed the fields I want to query into the form's table labeled "Drag query
fields here". I did the same with the data fields but placed them in the
table labeled "Drag data fields here". That includes the following fields:
StudentName, StudentID, ManagerID, Description, and DueDate. InfoPath
automatically created a Repeating Section in this table with the addition of
these fields.

Once that was done, I converted the student name field to a drop list and
pointed the list box entries to the StudentName field in the student
database. Based on your suggestion I added a Rule to this field to populate
the ID fields from the student database as well based on the Student Name
selected from the drop list being equal to the Student Name in the student
database. That's where I am currently. If there is more specific info I can
provide you, just point me to where I can find it and I will gladly post it.

Thanks for your patience.
 
U

Uncle Paulie

You'll have to forgive me Greg. As I said I'm an InfoPath newbie so I'm in
some uncharted territory here. The form has three data connections. The
first is the main connection - the SQL table where the student training
history is stored. The second is the table where the course information is
stored. The third is the student database where all of the student info is
stored. Upon creating a new form and establishing the Data Connections, I
draggeed the fields I want to query into the form's table labeled "Drag query
fields here". I did the same with the data fields but placed them in the
table labeled "Drag data fields here". That includes the following fields:
StudentName, StudentID, ManagerID, Description, and DueDate. InfoPath
automatically created a Repeating Section in this table with the addition of
these fields.

Once that was done, I converted the student name field to a drop list and
pointed the list box entries to the StudentName field in the student
database. Based on your suggestion I added a Rule to this field to populate
the ID fields from the student database as well based on the Student Name
selected from the drop list being equal to the Student Name in the student
database. That's where I am currently. If there is more specific info I can
provide you, just point me to where I can find it and I will gladly post it.

Thanks for your patience.
 
U

Uncle Paulie

You'll have to forgive me Greg. As I said I'm an InfoPath newbie so I'm in
some uncharted territory here. The form has three data connections. The
first is the main connection - the SQL table where the student training
history is stored. The second is the table where the course information is
stored. The third is the student database where all of the student info is
stored. Upon creating a new form and establishing the Data Connections, I
draggeed the fields I want to query into the form's table labeled "Drag query
fields here". I did the same with the data fields but placed them in the
table labeled "Drag data fields here". That includes the following fields:
StudentName, StudentID, ManagerID, Description, and DueDate. InfoPath
automatically created a Repeating Section in this table with the addition of
these fields.

Once that was done, I converted the student name field to a drop list and
pointed the list box entries to the StudentName field in the student
database. Based on your suggestion I added a Rule to this field to populate
the ID fields from the student database as well based on the Student Name
selected from the drop list being equal to the Student Name in the student
database. That's where I am currently. If there is more specific info I can
provide you, just point me to where I can find it and I will gladly post it.

Thanks for your patience.
 
G

Greg Collins

The drop-down is being populated with Names from somewhere. That "somewhere"
is critical to the process.
The assumption is that "somewhere" has Name, UserId, and ManagerID all
available and linked together in a single row of data.

So basically what needs to happen is:
A rule on the drop-down triggers when the value is changed. It sets the
value of the sibling field (UserId) by looking up the ID in the "somewhere"
data source, filtering for Name = Name_SelectedInDropDown.

Then it does the same for ManagerId.
 
U

Uncle Paulie

That's correct. The drop list values are populated from the Student database
(secondary data connection). The student name, student ID and manager ID are
all in the same record of the student info table. I added a rule to the
Student Name field setting the values of the student ID and manager ID fields
to their appropriate values based on the selected Student name in the drop
list matching the student name in the student database.

This all works correctly for the first new record in the repeating section.
When the next new record is added and a name is selected from it's drop list,
both ID fields are populated, but with the values from the first
record....not the values that are correct for the student name selected in
the second record.
 
G

Greg Collins

To what data source are the fields bound that you are trying to populate,
the main data source?

The XPath you provided previously doesn't seem to show that. It shows you
populating a value in a secondary data source based on a value in the main
data source instead of the other way around:

@LoginID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:CCS_TrainingHistory/@AssociateName
= ../@FullName]

The reason I know this is because of this part: xdXDocument:get-DOM(). This
instructs the XPath to go to the main DOM.

If your fields you are filling in are in the main DOM, the XPath should
probably look something more like this:

xdXDocument:GetDOM("Students")/Row/@LoginID[../@FullName =
current()/@AssociateName]

(Note: The above might not be the exact XPath you need, but is intended as
an example)

Note the use of the the function "current()". InfoPath 2007 is normally
pretty good about inferring this for you, and IP2003 never did. Though
sometimes you'll still need to manually reference it yourself. current()
represent the node or row you are "current"ly on when the action takes
place. It's a reference back to the exact location so you don't get lost
trying to do an full XPath like shown in your example.

For more on how to use current and do the kinds of things you are doing,
please look at the blog posts on InfoPathDev.com:

http://www.infopathdev.com/blogs/greg/archive/tags/Cascading/default.aspx
 
U

Uncle Paulie

Greg - Again I apologize. After looking at your post I realized I only
copied a portion of the xPath. Here is the xPath from the two rules that are
populating the ID fields:

For the Student ID field:

xdXDocument:GetDOM("Tracker")/dfs:myFields/dfs:dataFields/d:Tracker/@LoginID[../@FullName
=
xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:CCS_TrainingHistory/@AssociateName]

For the Manager ID field:

xdXDocument:GetDOM("Tracker")/dfs:myFields/dfs:dataFields/d:Tracker/@Manager[../@FullName
=
xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:CCS_TrainingHistory/@AssociateName]

Hopefully that makes more sense. I will check out the posts you referenced
and see if that provides me with a better understanding of where the problem
lies.

Thanks again for your assistance.
 
G

Greg Collins

Yes, please check out the posts. They are not directly related to your
issue, but close enough that it should help you figure it out.

Again, the issue lies with: xdXDocument:get-DOM() -- which causes the XPath
to start at the top of the main DOM.

xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:CCS_TrainingHistory/@AssociateName
should probably be something like:
current()/@AssociateName

But look through those blog posts.
 

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