Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Help With RemoveInstance

Avatar

Level 1

Hi

I'm trying to get RemoveInstance to work properly.  I want to create a button in a subform that will delete that specific subform.  Right now when I hit the delete button on the bottom most subform, the first one deletes instead.

Here is the button code I've been using, from what my searches turned up it should work.

form1.MeetingMinutesForm.Project.ProjectInfo.Delete::click - (JavaScript, client)

_Project.removeInstance(this.parent.index);

xfa.form.recalculate(1);


Many thanks

Mike

5 Replies

Avatar

Level 1

Hi Paulk07

Thanks for the suggestion, it looked promising but none of their steps worked.  I downloaded the latest sample pdf from that post and tried adapting the code to mine, but no go.  Tried some variations and previous suggestions, no luck.

Mike

Avatar

Level 6

try this: (java script on click event)

var nNodes = OrderSection.resolveNodes("OrderItems[*]").length;
if(nNodes > 1)
   OrderItems.instanceManager.removeInstance(this.parent.index);

Avatar

Level 1

Hi Paul

That didn't work, nothing happened. My subform is named Project, I replaced OrderSection with project, nothing happened.

Does it matter that the button is within a group?

Mike

Avatar

Level 1

Turns out the problem was all the objects within my subform were in a group including the button.  I ungrouped them, set my layout to western and all was good.

Thanks for all the suggestions