AEM forms check box to delete or add instances or similar actions | Community
Skip to main content
Level 2
September 26, 2025

AEM forms check box to delete or add instances or similar actions

  • September 26, 2025
  • 1 reply
  • 359 views

I have and AEM Designer built form. I can add row instances. 

 

What I need is in each row I want to include a check box and another button else where of the form.

 

And when I click this button It will refer to checked boxes in rows and perform tasks such as delete that instance or include a new instance below etc.

 

Do you have any idea how we can do that?  

1 reply

radzmar
Level 10
September 28, 2025

That's not a problem. Just run a for loop in reverse and add or remove the rows as needed.

Given you have a table "Table" with a repeatable row "Row" with a check box "CheckBox" in it, the script can look like this.

var oRows = Table.resolveNodes('Row[*]'), // resolve existing rows i = oRows.length - 1; // declare instance variable // Loop through all rows backwards for (i; i >= 0; i -= 1) { var oRow = oRows.item(i); // reference the nth row // Check the checkbox in the row. // If active, add row below if (oRow.CheckBox.rawValue === 1) { Table._Row.insertInstance(i + 1, true); oRow.CheckBox.rawValue = 0; // Otherwise remove current instance } else { Table._Row.removeInstance(i); } }