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.

Remove subform instance problem

Avatar

Level 4

HI there

I am using the following code to remove the last subform instance

subform.instanceManager.removeInstance(1)

However in test it appears to be removing the last instance but one.

Can anyone help me fix this.

Thanks

Darren

2 Replies

Avatar

Former Community Member

Instance numbers are 0 based ......so the command shoudl be removeInstance(0)

Paul

Avatar

Level 4

Hi Paul

Many thanks for your quick response.  When I added that to my form it removed the first instance rather than the last instance.  I had a look on the links here and for any one else that has a similar prob the following seems to have fixed the problem

subform.instanceManager.removeInstance(subform.instanceManager.count-1)

Thanks again

Darren