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

SOLVED

use of addInstance

Avatar

Level 2

Hello,

I'm trying to use AEM Forms addInstance() method inside a MasterPage to instantiate multiple times, via a for loop, a subform (placed outside the Master Page). The result is that it calls the document multiple times, it goes into an infinite loop. Is it not possible to use addInstance() in this way in a MasterPage??

1 Accepted Solution

Avatar

Correct answer by
Level 10

@utente2 just put on form ready or somewhere except master page and test.

View solution in original post

0 Replies

Avatar

Level 4
This does not sound like any good practice that I know 🙂 What do you mean "outside a master page"? Infinite loop is probably your for loop where the end criterium does not come about. Masterpages have different rules compared to normal pages. Can you draw some concept of what you are trying to achieve?

Avatar

Correct answer by
Level 10

@utente2 just put on form ready or somewhere except master page and test.

Avatar

Level 2

In a template I have to import a fragment. In this fragment I want to create several instances of a subform and for each of these I check if the number of pages of the fragment has changed as the number of instances of the subform increases. For example, if after 5 iterations the fragment from 1 page goes to 2 pages I have to hide an element that is on the first page and modify another element that is on the next page.

I thought about using the master page because from here I could read the value of xfa.layout.page (this), but I had to put the rest of the code (the loop with addInstance()) inside it too