Expand my Community achievements bar.

Reference instance of a repeatable subform in form validation script

Avatar

Level 3

I'm back again!

I have a couple of repeatable subforms within my form - thanks to help on here, I'm not having any issues with them apart from when I validate the contents of my form.

I have a button (regular) that validates the completed form via the following click event - validateForm.checkForm(xfa.form)

So, I'm sending the whole form through to the checkForm javascript function.

I can get a count of the instances of my repeatable subforms as follows -

var

mtAPMV = completedForm.subform1.subform2.subform3.subform4._repeatableSubform;

var numMTInsts = mtAPMV.count;

I then stick it in a for loop but am unable to reference the instance of my repeatable subform - I've tried resolveNode but am assuming because I'm not actually referencing the 'real' names it doesn't work -

var

mtAPMVehArea = xfa.resolveNode("myForm.subform3.subform4.repeatableSubform["+i+"]");

var mtAPMVArea = myForm.subform3.subform4.repeatableSubform[i];

I'm either getting 'undefined' or 'null' or nothing!

Any ideas?

Thanks,

1 Reply

Avatar

Level 3

Well I've sorted it!

I thought I was being careful/clever/something by sending through the form to the checkForm function but I didn't need to!

Instead I'm referencing xfa.form directly in my function & can now reference each instance of my repeatable subform like so:

var

mtAPMVehAreas = xfa.resolveNodes("xfa.form.subform1.subform2.subform3.subform4.subform5[*]");

var numMTInsts = mtAPMVehAreas.length;

for (var i=0; i<numMTInsts; i++)

{

     var mtAPMVehArea = mtAPMVehAreas.item(i);

Probably obvious to some but I'm on a (very steep) learning curve with LiveCycle!