automatically number items in repeating table

J

Janie

I have a repeating table and would like the first column (I'm calling Item
No.) to automatically fill in with numbers in the order the items are entered.
 
G

Greg Collins [InfoPath MVP]

If you are storing the number, set the default value formula to: position()

If you are not storing the number, use an expression box with the same formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm calling Item
No.) to automatically fill in with numbers in the order the items are entered.
 
J

Janie

Greg, that worked for the first item. But then when I click "insert item,"
the number still comes up as the number 1, instead of the next number (in
this case 2).
 
P

Philip Colmer

Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node of
the repeating row.

--Philip

Janie said:
Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next number (in
this case 2).

Greg Collins said:
If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm calling
Item
No.) to automatically fill in with numbers in the order the items are
entered.
 
J

Janie

thank you, Philip. I get a message saying this: Invalid number of arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

Philip Colmer said:
Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node of
the repeating row.

--Philip

Janie said:
Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next number (in
this case 2).

Greg Collins said:
If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm calling
Item
No.) to automatically fill in with numbers in the order the items are
entered.
 
P

Philip Colmer

No - you want the name of the node above it.

--Philip

Janie said:
thank you, Philip. I get a message saying this: Invalid number of
arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

Philip Colmer said:
Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node of
the repeating row.

--Philip

Janie said:
Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next number
(in
this case 2).

:

If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm calling
Item
No.) to automatically fill in with numbers in the order the items are
entered.
 
J

Janie

Okay, so the node above it will just have a default value of 1. But since
it's a repeating table, there is no "second node". Should I create a hidden
node to be the parent node?

Philip Colmer said:
No - you want the name of the node above it.

--Philip

Janie said:
thank you, Philip. I get a message saying this: Invalid number of
arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

Philip Colmer said:
Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node of
the repeating row.

--Philip

Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next number
(in
this case 2).

:

If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm calling
Item
No.) to automatically fill in with numbers in the order the items are
entered.
 
P

Philip Colmer

Sorry - it is my terminology that I think is confusing :).

You've got a field called TouchItemNo. What you need is for the position
calculation to refer to the GROUP that contains TouchItemNo.

If you are still struggling, open the Purchase Request sample that comes
with InfoPath. The equivalent to TouchItemNo is the Item Number in the
itemized list. The group that contains itemNumber is called item - you need
to put in the name of the group that contains TouchItemNo.

Hope that helps a bit more.

--Philip

Janie said:
Okay, so the node above it will just have a default value of 1. But since
it's a repeating table, there is no "second node". Should I create a
hidden
node to be the parent node?

Philip Colmer said:
No - you want the name of the node above it.

--Philip

Janie said:
thank you, Philip. I get a message saying this: Invalid number of
arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

:

Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node
of
the repeating row.

--Philip

Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next
number
(in
this case 2).

:

If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the
same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm
calling
Item
No.) to automatically fill in with numbers in the order the items
are
entered.
 
J

Janie

Philip, I looked at the Purchase Request template, but I noticed that the
field "Item Number" field does not number itself as I add items to the list.

I tried this function, but got errors: position(preceding-sibling::group2)
+ 1
I also tried count(preceding-sibling::group2) + 1 did not work

Thanks for putting up with me.

Philip Colmer said:
Sorry - it is my terminology that I think is confusing :).

You've got a field called TouchItemNo. What you need is for the position
calculation to refer to the GROUP that contains TouchItemNo.

If you are still struggling, open the Purchase Request sample that comes
with InfoPath. The equivalent to TouchItemNo is the Item Number in the
itemized list. The group that contains itemNumber is called item - you need
to put in the name of the group that contains TouchItemNo.

Hope that helps a bit more.

--Philip

Janie said:
Okay, so the node above it will just have a default value of 1. But since
it's a repeating table, there is no "second node". Should I create a
hidden
node to be the parent node?

Philip Colmer said:
No - you want the name of the node above it.

--Philip

thank you, Philip. I get a message saying this: Invalid number of
arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

:

Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node
of
the repeating row.

--Philip

Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next
number
(in
this case 2).

:

If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the
same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm
calling
Item
No.) to automatically fill in with numbers in the order the items
are
entered.
 
G

Greg Collins [InfoPath MVP]

position(preceding...) is definitely wrong. Position doesn't take any parameters. You definitely want to use count().

You likely need to discover the correct XPath. It could be:
count(../preceding-sibling::group2) + 1
or something else based on the schema you have. An understanding of XPath and the current location the path is starting from will make things easier.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Philip, I looked at the Purchase Request template, but I noticed that the
field "Item Number" field does not number itself as I add items to the list.

I tried this function, but got errors: position(preceding-sibling::group2)
+ 1
I also tried count(preceding-sibling::group2) + 1 did not work

Thanks for putting up with me.

Philip Colmer said:
Sorry - it is my terminology that I think is confusing :).

You've got a field called TouchItemNo. What you need is for the position
calculation to refer to the GROUP that contains TouchItemNo.

If you are still struggling, open the Purchase Request sample that comes
with InfoPath. The equivalent to TouchItemNo is the Item Number in the
itemized list. The group that contains itemNumber is called item - you need
to put in the name of the group that contains TouchItemNo.

Hope that helps a bit more.

--Philip

Janie said:
Okay, so the node above it will just have a default value of 1. But since
it's a repeating table, there is no "second node". Should I create a
hidden
node to be the parent node?

Philip Colmer said:
No - you want the name of the node above it.

--Philip

thank you, Philip. I get a message saying this: Invalid number of
arguments.

-->position(preceding-sibling::TouchItemNo)<-- + 1

The "TouchItemNo" is the name of the field in the repeating table I am
trying to get to number. Is that the same as the parent node?

:

Try this:

count(preceding-sibling::item) + 1

You will probably need to change "item" to the name of the parent node
of
the repeating row.

--Philip

Greg, that worked for the first item. But then when I click "insert
item,"
the number still comes up as the number 1, instead of the next
number
(in
this case 2).

:

If you are storing the number, set the default value formula to:
position()

If you are not storing the number, use an expression box with the
same
formula: position()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a repeating table and would like the first column (I'm
calling
Item
No.) to automatically fill in with numbers in the order the items
are
entered.
 

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