Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Remove instance of row in section

Avatar

Level 2

I have tried everything that I can think of to get the Remove Instance button to work to remove the CURRENT instance but I can't figure it out.

Basically I have a table with a section.  Within this section I have one row that the user can add more instances of. I added a remove instance button but it acts erratically and I can't get it to remove the CURRENT instance. Sometimes it deletes the first instance..sometimes the last instance in the repeating section...it's all over the place and I can't figure out why.

Code for Remove instance button: 

this.resolveNode('PackageSection._ItemRow').removeInstance(this.parent.index);

if (xfa.host.version < 😎 {

  xfa.form.recalculate(1);

}

Hierarchy for table:

Page1>

   Column2Subform>

         Table1>

              PackageSection>

                               ItemRow (this has a cell subform with the add/remove instance buttons)

Any guidance would be appreciated.  Link to actual form:  Untitled3Sample.pdf

1 Accepted Solution

Avatar

Correct answer by
Not applicable

Use the following script on the click event of - button:

topmostSubform.Page1top.Column2.Table1.PackageSection._ItemRow.removeInstance(this.parent.parent.index);

Hope this hleps.

Thanks

4 Replies

Avatar

Correct answer by
Not applicable

Use the following script on the click event of - button:

topmostSubform.Page1top.Column2.Table1.PackageSection._ItemRow.removeInstance(this.parent.parent.index);

Hope this hleps.

Thanks

Avatar

Level 2

Thanks so much, but it's not working still.  That's the problem that I am having..the code is ok and it works for the first instance of the table section. But if I add more instances of the table sections the buttons don't work at all. I suspect it has something to do with the form construction or another setting and not so much with the script

Avatar

Level 2

I found a workaround. My problem occurred when I added another instance of the table section.   The code for add/remove instances would work on the first section but not on subsequent instances.

I decided to split the table..convert my header row to a standalone textfield and the repeatable row into a one row table.  Then I wrapped the table and textfield in a subform to create my table 'section.'  All codes for removing/adding instances work as they should now.

Avatar

Not applicable

Just FYI, The form is working as expected when i downloaded your form and added the suggested script. Not sure why it is not working for you. Anyways, if your workaround is working Cheers ! Thanks

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 81, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 81, column 5] ----