Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Removing an instance

Avatar

Level 2

Hello everyone, I can not remove an instance. Currently I have a subform with add/remove button which adds a row not only to the subform of SF1 but also adds a row to SF7 of a different Section. So my addrow script looks like the below and is applied to SECTION1.SFTABLE2.Table14.Row1.: var newRow = SECTION3.SF7.instanceManager.addInstance(1); newRow.presence = "visible"; I'm having trouble removing the newRow. Anyone can help would be great! Kr, Nancy

4 Replies

Avatar

Level 10

Hi Nancy,

The command would be SECTION3.SF7.instanceManager.removeInstance(index);  where index will be the index of the row you want to remove.  newRow will have an index property so SECTION3.SF7.instanceManager.removeInstance(newRow.index) will remove the row just added.

You haven't given us enough information to know how to calculate the index.  If you delete button is under the SF7 in the form structure then you can try this code;

SF7.instanceManager.removeInstance(SF7.index);

Regards

Bruce

Avatar

Level 2

Hi Bruce, Thank you for your feedback. My heirarchy is as follows: I have 2 Master Pages and 4 Sections Section 1 is where I have the delete button, I have 5 subforms in this section and the delete button is in SFTABLE2.Table14.Row1. My coding for adding a row here is: var newRow = SECTION3.SF7.instanceManager.addInstance(1); newRow.presence = "visible"; // this is because I want to make the row visible since the field itself is hidden. The row that appears is in SECTION3.SF7. I hope this helps. Thanks! Nancy

Avatar

Level 10

Hi Nancy,

What we need to know is how the delete button will work out which row it has to delete.  Did you try the "SF7.instanceManager.removeInstance(SF7.index);" code.

Happy to look at your form is you upload it to Google Docs (or somewhere) you can add a link to this thread.

Regards

Bruce

Avatar

Level 2

Hi Bruce, I unfortunately cant upload anything anywhere from work. Can I send it to your email add? Furthermore, I did try the code you gave me but it didnt work... also tried different variations but still no luck. Cheers, Nancy