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

REFERENCING INSTANCES OF A SUBFORM IN SCRIPT

wdoughertyiii
Registered: Jul 27 2009
Posts: 5

Greetings:
 
BACKGROUND INFO: I am creating a Travel Application / Reimbursement form in which I need to make the reimbursement column of fields "hidden" (application phase) or "visible" (reimbursement phase). I am using many scripts like the one below to reference each field (labelled a,b,c,...aa,bb,cc...) placed under the click event of a button (I tried using a drop-down box to select "Travel Application" or "Reimbursement Request" but the results were not consistent).
 
if(xfa.resolveNode("#subform.EstimateofExpenses.Table2.Row1[1].b").presence=="hidden")then
xfa.resolveNode("#subform.EstimateofExpenses.Table2.Row1[1].b").presence="visible"
elseif(xfa.resolveNode("#subform.EstimateofExpenses.Table2.Row1[1].b").presence=="visible")then
xfa.resolveNode("#subform.EstimateofExpenses.Table2.Row1[1].b").presence="hidden"
endif
 
PROBLEM: One of my fields is set with the ability to have multiple instances. The show/hide scripts work on all fields except for the instances. I do not know how to reference the other instances in script...
 
If anyone could give some pointers on this, it would be much appreciated. Thanks!

Will Dougherty III

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You will need a for loop to address all instances of an object.
Here an example in FormCalc.

1: Count the current instances of your repeatable object.
var nRow = Table2.Row1.instanceManager.count
2: Initiate the loop
  1. for (i = 0 upto nRow -1 do)
  2. Table2.Row1[i].b.presence = "hidden"
  3. endfor
If you use FormCalc it's generally not necceassary to use the resolveNode method because FormCalc can address objects much easier than JavaScript!
The benefit is a much slimmer script syntax.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs