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.

addInstance not working on button click

Avatar

Former Community Member
I have a row table bound to a list on xsd and it is working fine, displaying all rows present on my xml.



I created a button in order to add rows to this table, for the user to fill in data. On the Javascript click event of the button I added the addInstance(true) with no success. However, the same code snippet is able to add instances of the row if placed on the initialize event of the same button!



This is the code:

TablePagamento._RowPagamento.addInstance(true);



So, why isn't the click event working but the initialize is?



By the way, my form has 3 different master pages, and I am beggining to think this is the problem, since I can make the above code work on a blank form with a single master page.
6 Replies

Avatar

Former Community Member
Are you defining your form as a dynamic form?

Avatar

Former Community Member
My guess is that the subform TablePagamento is in a different context that the button so it cannot be found. Try pathing your way from the root all the way down to the subform.....so it should look something like this:



form1.Page1.TablePagamento._RowPagamento.addInstance(true);

Avatar

Former Community Member
Still not working, even with the full path

Avatar

Former Community Member
Can you post your form and any associated data files or schemas to livecycle8@gmail.com and I will have a look at it.

Avatar

Former Community Member
Hi Marcelo,



It all has to do with (look here)



1) UPPER Subform CONTENT must be FLOWED

2) Min Occurence/Count & Max Occurence/Count

a) For Subforms check Binding Tab (Repeat Subform for each data item)

b) For Components Check Min Count & Max Count



If you have multiple Subforms within Subforms within Subforms...

definatly check the above two points, they will sort you out!



Advice.



Start a new document. Try it with one Subform. MAke it work, then add another subform that encapsulates the original subform and try make it work.. etc! until it represents your form structure! You will learn how the min/max works.