Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Delete multiple table rows.

Avatar

Level 2

How do I delete multiple table rows at once?

I have a table with 10 rows.

I have a for loop to delete rows 1, 3 and 6.

It deletes row 1 and 3 and the Index out of Bounds exception.

I know why this is happening.

I am looking for a function or something to delete multiple rows all at once?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

It should be a logical mistake.

For every row you delete, you should decrease the index count.

For e.g

If you want to delete rows 1,3 and 6 from a table which contain 6 rows

delete row1  as Table.Row[0].instanceManager.removeInstance();     [now the row count will become 5]

delete row3  as Table.Row[1].instanceManager.removeInstance();     [note that index is 1 because you already deleted one record, and index starts from 0]

delete row6 as Table.Row[3].instanceManager.removeinstance();      [already two record deleted, so 6-2-1= 3 is your index to delete]

Do you understand the logic?

Nith

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

It should be a logical mistake.

For every row you delete, you should decrease the index count.

For e.g

If you want to delete rows 1,3 and 6 from a table which contain 6 rows

delete row1  as Table.Row[0].instanceManager.removeInstance();     [now the row count will become 5]

delete row3  as Table.Row[1].instanceManager.removeInstance();     [note that index is 1 because you already deleted one record, and index starts from 0]

delete row6 as Table.Row[3].instanceManager.removeinstance();      [already two record deleted, so 6-2-1= 3 is your index to delete]

Do you understand the logic?

Nith

Avatar

Level 2

You are correct.

Changed my logic and it works perfectly now.

Thanks.