Expand my Community achievements bar.

SOLVED

removeInstance with delete button

Avatar

Level 5

I created a form with a button to remove the current action item via script. Although I have reviewed this script repeatedly, and used the Add Action for the button I still cannot get the button to remove the Current instance. The button always removes the first instance. Does anyone have any answers with this problem? Is my hierarchy wrong for this action?

Delete Button.JPG

Delete Button 3.JPG

1 Accepted Solution

Avatar

Correct answer by
Level 10

What code is on the delete button now?

It's unclear what you're trying to delete, is it the CorrAction subform?

If it's the "CorrAction" subform you would need:

_CorrAction.removeInstance(this.parent.parent.index);

As CorrAction is 2 levels (parents) above the delete button.

If it is "Action" you are trying to delete then you would need:

_Action.removeInstance(this.parent.parent.parent.index);

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

What code is on the delete button now?

It's unclear what you're trying to delete, is it the CorrAction subform?

If it's the "CorrAction" subform you would need:

_CorrAction.removeInstance(this.parent.parent.index);

As CorrAction is 2 levels (parents) above the delete button.

If it is "Action" you are trying to delete then you would need:

_Action.removeInstance(this.parent.parent.parent.index);

Avatar

Level 5

this.resolveNode('Fourteen._Action').removeInstance(this.parent.index);

if (xfa.host.version < 8) {

    xfa.form.recalculate(1);

}

the subform I am trying to delete is "Action". "CorrAction" is a subform of "Action". The "Action"subform adds the delete box to the contents of "CorrAction". If fixed it with your with one more parent.

this.resolveNode('Fourteen._Action').removeInstance(this.parent.parent.parent.index);

if (xfa.host.version < 8) {

    xfa.form.recalculate(1);

}

Thanks again Jono!