Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

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

Avatar

Level 2

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

Avatar

Level 10

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);
	}
}