These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Dynamically Numbering Subforms

realname
Registered: Aug 15 2008
Posts: 93
Answered

I have a subform witch allows the user to add or delete another instance. What I would like in this subform is a "record number". For example, in the existing subform, I would like a text or numeric field to be "record 1". If the user creates a new subform, I would like it to dynamically say "record 2" and so on for each subform added so the user does not have to remember what record they may be on if they have several. I am also wondering with this how the numbering would work or if there is a choice? For example, if there are three instances of the subform, numbered 1, 2 and 3 and the user deletes #2, will or can number 3 renumber itself to #2?
 
I have a feeling there is a relatively simple solution to this but do not know how to do this or where to look for a solution.
 
Any help would be greatly appreciated!

My Product Information:
LiveCycle Designer, Windows
realname
Registered: Aug 15 2008
Posts: 93
After a lot more searching I found this solution to my question.

In the initialize event, I put:
this.rawValue=Recommend.instanceManager.count;

This works exactly how I want it to that when another subform is added, it increments the number by 1 however, if I remove a subform instance, the numbering does not renumber for example, if I have subform 1, 2 and 3, remove 2, subform 3 does not renumber to 2 but stays at 3.

Is there a way these can renumber correctly?

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
As the initialize:Event only occurs once, the script is not fired again when you add or remove instances.
Use the layoutReady:Event instead.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

realname
Registered: Aug 15 2008
Posts: 93
I put the script into the layoutReady event however, when I add an instance of the subform, the number changes in all the subforms to the number of instances counted instead of incrementing. With 3 instances of the subform, each one displays the number 3 instead of 1, 2, 3.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Well,

the count will always represent the number of all instances.
Use the index property instead.
this.rawValue = (Recommend.index + 1).toString();

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

realname
Registered: Aug 15 2008
Posts: 93
Perfect! Thank you so much. I had come across something in my search on how to do this that referenced index but I wasn't sure how to apply it.

Thank you again!