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

Action "remove field" always removes first instance

Avatar

Level 1

I hope I'm explaining this clearly.

I have a section that includes a text box, a few drop down boxes and 4 buttons. This entire section is repeated when one of those four buttons "add" is selected. The forms drops down to make room for the new section.

You can do this as many times as needed. And each new section has the same 4 buttons. Two relevant ones are "add" and "remove" the section.

The issue I'm having is that when you select the "remove" button in ANY of the new (or original) sections, it only removes the original section (or first one if you keep selecting it). The action for that button is set to remove "current instance". If I change to the other options "first instance" "last instance" or instance #, it completes that correctly. But "current instance" always removes the first instance.

I'm thinking the issue might be in how the "add" section includes the buttons themselves.

Any thoughts on what I could do differently or what the issue might be?

1 Reply

Avatar

Level 7

In case you still need an answer....I would have the add button outside the repeated subform

My subform is called sf

btnAdd: click (javascript)

this.resolveNode('form1.#subform._sf').addInstance(1);

if (xfa.host.version < 😎 {

xfa.form.recalculate(1);

}

btnRemove: click (Javascript)

this.resolveNode('form1.#subform._sf').removeInstance(this.parent.index);

if (xfa.host.version < 😎 {

xfa.form.recalculate(1);

}

This remove button should remove the subform where the button is clicked. I have had a problem like described as well. This code works for me, but have found when i have had problems i changed this.parent.index to this.sf.index and it worked as desired.