Highlighted

Dynamic subform validation

SnookerDJ

13-02-2009

Hi there



I have a form that when you click a button it repeats an instance of a subform.



I have also added an additional 'validation' button so that it checks that some of the fields in the subform are filled in. I have used some JavaScript for this. The validation works fine on the first instance. However, it does not work on the second instance on the subform. I know that somehow I must get the script to check for extra instances but I cannot work it out.



Any help would be greatly appreciated.



Thanks

Replies

Highlighted

pguerett

13-02-2009

You will have to put your code in a for loop where you can get the count of subforms to test. Now that you know the number of times to loop through the for loop, you can access each individual item of the subform using this notation:



form1.Page1.subform1.repeatingsubform[x].fieldname.property/method



To be able to derive the Som Expression and use the counter in the for loop you can use this notatoin:



xfa.resolveNode("form1.Page1.subform1.repeatingsubform[" + counter + "]").fieldname.....



This allows your expression to increment as the counter increments and will update each row as required. Note that the instance numbers are 0 based.
Highlighted

SnookerDJ

13-02-2009

Hi Paul



Many thanks for your reply. I am new to LiveCycle and picking up things and learning as I go along so I didnt fully grasp where to input the code or if it needs to go into a different event. Would you be able to put your example into context with the validation script I have runnning on the click event of a button in my form.



if ((HigherEducationPage.QualificationSubform.course.rawValue == null) || (HigherEducationPage.QualificationSubform.course.rawValue == "")) {

app.alert("Please enter your course in Section 1 of this form.");



Many thanks



Darren
Highlighted
Highlighted

pguerett

13-02-2009

It woudl be easier to add the code and show you that way. If you send the file to livecycle8@gmail.com I will add the code when I get a chance.