Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Remove a specific table instance

Avatar

Level 3

I have a subform with a table in it. I have a two buttons in the table. The addTable button adds another instance of the subform (i.e. a new table). The delTable button is supposed to delete the table I am in. The code for remove is _subform.removeinstance(this.parent.index). The problem is that the remove button always removes the first table and not the table specific to itself:

Example 1: have table 1 and add another table. Hit delete on table 2 and it deletes table 1. Hit delete on Table 1 and it removes table 1 leaving table 2.

Example 2: have table 1 and add 2 tables. Hitd delete on table 2 and it deletes table 1. Hit delete on Table 3 and it removes table 1. Hit delete on table 1 and it deletes table 1.

What I would like it to do is to delete table 2 if that is the table I choose to delete. Anyone know what the code for that would be?

Thanks,

Mallard27

1 Accepted Solution

Avatar

Correct answer by
Level 5

It depends on your hierarchy when you say this.parent.index in your code. You need to find the correct repeating subform index which maybe a couple of levels above your current context. If you have a repeating table in a subform and you button is inside a row of the subform it could be that you should have this.parent.parent.parent.subform.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

It depends on your hierarchy when you say this.parent.index in your code. You need to find the correct repeating subform index which maybe a couple of levels above your current context. If you have a repeating table in a subform and you button is inside a row of the subform it could be that you should have this.parent.parent.parent.subform.

Avatar

Level 3

Thanks Dohanlon! (this.parent.parent.parent.index) resolved the issue.