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.

Working with addInstance

Avatar

Former Community Member
I have worked with adding more instances of subForms but only adding more to the end.



How do I add an instance after a certain subForm?



For example, if I have 6 instances of a subForm and I want to insert another instance of the subForm after number 3 how do I do it?



Or can it be done?
6 Replies

Avatar

Former Community Member
Hi Steven, you just need to change your current position for the addition:



var oSubform = this.resolveNode("Subform2");

var oNewInstance = oSubform.instanceManager.addInstance(1);

var nIndexFrom = oNewInstance.index;

var nIndexTo = this.parent.index + 1;



// Invoke the instanceManager to insert the subform below the current one.

oSubform.instanceManager.moveInstance(nIndexFrom, nIndexTo);

Avatar

Former Community Member
Lee,



Thanks for the quick response. I tried the code you sent and it does add a new instance the subForm but not in the way I was expecting. Here is what my subForm is made of.



The subForm called "imageInfo" is 744 points wide by 36 point tall and consists of several text field next to each other. There are two button on the left side. One that deletes the subForm and one that I want the user to click and it will add a new blank subform below it.



When I tried the code a copy of the bottom most subForm was added to the bottom.

Avatar

Former Community Member
As I have been playing around with this it looks like what is happening is when a new instance of the subForm in added and put in the right place it assumes values of the check boxes from the subForm that was in that position previously. They can't be unchecked. At least that is what is happening in Preview mode.



It looks like they just have the appearance of being checked but really aren't. I'm just guessing at this point but it seems like that is what is happening. I have noticed that when it get to the point where a so many new instances are added so a new page is added then the check boxes that have the appearance of being checked are no longer checked. Strange.



I suppose I could post the form if anyone is interested in seeing how it is working.

Avatar

Former Community Member
Hi Designer Experts,



Im getting in very similar troubles to those pmhsilva@adobeforums.com faced in July 2005 (http://adobe.groupbrowser.com/threadpage49976-1-10.html) I tried different ways to make the addInstance method work, without any success. Just like pmhsilva, I dont see the method addInstance in the code completion feature, but Im using a brand new download of designer (version 7, 0, 041126). More surprisingly, should I write addInstance or addInstances, nothing happens, I dont even get an error message; what is type after instanceManager. seems just to be ignored (same trouble with setInstance for example)! Should the method be manually registered in one or another way ?



Could you help me solve it ?



Tx !







Etienne

Avatar

Former Community Member
Etienne,



Make sure that you save your form as a dynamic PDF. For examples of using the instanceManager see
http://partners.adobe.com/public/developer/en/xml/Adobe_XML_Form_Object_Model_Reference.pdf.



Denver

Adobe Enterprise Support

Avatar

Former Community Member
Thanks Denver,

my form was saved as dynamic PDF. But... the subform container type was set to "positionned content", so each new instance was over the previous one, giving the impression of no change! Once the type was set to "Flow Content", everything worked fine! -but I still have no automatic completion after ".instanceManager" -OK it doesn't matter as it works! It really worth paying attention at complete characteristics of the examples, not only the code.



Etienne