use of addInstance | Community
Skip to main content
Level 2
September 2, 2020
Solved

use of addInstance

  • September 2, 2020
  • 3 replies
  • 1366 views

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??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mayank_Gandhi

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

3 replies

Kosta_Prokopiu1
Adobe Employee
Adobe Employee
September 2, 2020
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?
Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
September 2, 2020

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

utente2Author
Level 2
September 2, 2020

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