Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

add instance in a subform which also can be doubled

Avatar

Former Community Member
Hi,



I have a subform X which can be doubled by a click on the button. In that subform X there is another subform Y which also can be multiplied to a maximum of 3.



Now when I add a subform X and i want to add some subforms Y. The form will only add the subform Y in the first subform X and not in the second one.



This is the script I use:



for subform x



if(Incitant52.subFoireAcheteur.all.length < 2){;

Incitant52.subFoireAcheteur.instanceManager.addInstance(true);

}



and for subform y



if(Incitant52.subFoireAcheteur.subAcheteur.all.length < 3){;

Incitant52.subFoireAcheteur.subAcheteur.instanceManager.addInstance(true);

}
3 Replies

Avatar

Former Community Member
To add instances to the second occurance of subform x you will need to address it with subformx[1].



Note that the [ ] brackets are not valid in javascript so your expression should look something like this:



xfa.resolveNode("Incitant52.subFoireAcheteur.subformx[1]").instanceManager.addInstance(1)

Avatar

Former Community Member
Thanks for the help. I already tried to change the script but my designer always crashes.



But I can keep it in javascript?



Can i also use the brackets with javascript for a calculation?

Avatar

Former Community Member
Yes ...but again you will have to use the xfa.reolveNode syntax to address the correct instance.