Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Dynamic population issue with repeated sub form

Avatar

Level 2

I have a subform that populates a dropdown from another subform on a prior page. In the Enter event on the subform I have the following script:

Drop Down 1

this.clearItems();
this.rawValue = null;
this.fontColor = "0,0,0";

var nCount = Subform3.Subform2.Subform1.instanceManager.count;
console.println("nCount: " + nCount);

for (var i=0; i<=nCount; i++)
{
var vFld = xfa.resolveNode("Subform3.Subform2.Subform1[" + i + "]");
var vItem = vFld.RiskNo.rawValue;
this.addItem(vItem.toString());
}

A second drop down is also populated in the PostOpen event on the subform with the following script:

Drop Down 2

this.clearItems();
this.rawValue = null;
this.fontColor = "0,0,0";

var sf1 = Subform3.Subform2.resolveNodes ("Subform1[*]");
for ( var i = 0; i < sf1.length; i++)
{
if (CTPData.RiskRow.Risk.rawValue == sf1.item(i).RiskNo.rawValue)
{
  var controlsf = sf1.item(i).resolveNodes ("Controls.Control[*]");
  for ( var j = 0; j < controlsf.length; j++)
  {
   var wInput = controlsf.item(j).ContNo.rawValue;
   this.addItem(wInput.toString());
  }
}
}

I then populate a text field with values based on drop down selections with the following Exit Event scripts:

Exit Event Drop Down 1 to populate text field 1

var sf1 = Subform3.Subform2.resolveNodes ("Subform1[*]");
for (var i = 0; i < sf1.length; i++)
{
if (CTPData.RiskRow.Risk.rawValue == sf1.item(i).RiskNo.rawValue)
  {
   var wInput = sf1.item(i).RiskInput.rawValue;
   CTPData.RiskRow.RiskTxt.rawValue =(wInput);
   CTPData.ControlsRow.ControlTxt.rawValue = "";
  }
}

Exit Event Drop Down 2 to populate text field 2

var sf1 = Subform3.Subform2.resolveNodes ("Subform1[*]");
for ( var i = 0; i < sf1.length; i++)
{
if (CTPData.RiskRow.Risk.rawValue == sf1.item(i).RiskNo.rawValue)
  {
  var controlsf = sf1.item(i).resolveNodes ("Controls.Control[*]");
  for ( var j = 0; j < controlsf.length; j++)
 
if (CTPData.ControlsRow.Control.rawValue == controlsf.item(j).ContNo.rawValue)
  {
   var wInput = controlsf.item(j).ControlInput.rawValue;
   CTPData.ControlsRow.ControlTxt.rawValue =(wInput);
  }
}
}

These scripts work absolutely perfect for the first instance of the subform they are on.  On added instances of the subform however, the drop downs work but the populate text fields from the selected values do not.

I am sure I am missing something simple but I can’t find it.

I would greatly appreciate any pointers I could get.

Thanks,
Eagle

2 Replies

Avatar

Level 10

Hi,

For starters I would move the reference to RiskNo up to the resolveNodes():

var sf1 = Subform3.Subform2.resolveNodes ("Subform1[*].RiskNo");

for (var i = 0; i < sf1.length; i++)

{

if (CTPData.RiskRow.Risk.rawValue == sf1.item(i).rawValue)

  {

Niall

Avatar

Level 2

I actually tried that with the same results.  It seems to me that the issue is that

var wInput = controlsf.item(j).ControlInput.rawValue;

CTPData.ControlsRow.ControlTxt.rawValue =(wInput);

on the repeated subform has a different CTPData.ControlsRow.ControlTxt.  something like CTPData.ControlsRow.ControlTxt(0). but I don't understand enpough about repeated subform values to figure it out.

Thanks,

Eagle