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 subform validation

SnookerDJ
Level 4
Level 4
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
4 Replies
pguerett
Level 10
Level 10
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.
SnookerDJ
Level 4
Level 4
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
SnookerDJ
Level 4
Level 4
Also can you explain how the for loop works as well and where I would need to add it in.



Thanks again



Darren
pguerett
Level 10
Level 10
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.