Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

addInstance Help Needed

Avatar

Level 2
I am a newbie working with LiveCycle Designer 7.0 to create my very first form. I am having a little difficulty getting some buttons to work the way I need them to work. I have a button that recreates the text fields from the subform of another subform (this works properly). The second button recreates the main subform (including its subform), and this works properly. However, when I use the second button and the main subform is recreated, the first button still only adds fields to the original subform of the subform. How do I get it to work with each new subform created by the second button? I have tried several different methods but haven't had any luck.
8 Replies

Avatar

Former Community Member
I'm having a hard time understanding exactly what these buttons do. Are you using the Instance Manager to create new instances of the subform (from the second button)? How exactly are you recreating the text fields ?



It sounds like you're simply wanting to generate a new instance of a subform which contains text fields. You can achieve this simply by placing the subform which will have many instances (the Dynamic Subform) in a flowed container and then setting the Dynamic Subform's Initial Count property on the Object palette's Binding tab to a desired number of initial instances. Then you would have a single button which, when clicked, would invoke the Dynamic Subform's Instance Manager to add a new instance of the subform which would, at the same time, replicate all the fields within the subform into the new instance.



I've attached a sample for which has a button that, when clicked, generates a new instance of a subform containing a few fields. Check it out and see if this is similar to what you're looking for.



Stefan

Adobe Systems

Avatar

Level 2

It sounds like your solution for adding an instance of a sub form is what I need but I don't see your

example on the web page. could I see it too?

Avatar

Level 2
What I have is a subform of a subform...subform 1 and subform 1a. Button 1 uses addInstance to allow the user to add as many fields as needed in subform 1a. Initially this button works. Button two is used to generate a new instance of subform 1 (which includes subform 1a), and this works as well. However, once button two is used and the new instance appears on the form, button one still reacts by adding an instance of subform 1a in the original subform...not on the newly generated instance. The rest of the form works well, but of course this is the one part that isn't cooperating.

Avatar

Former Community Member
Jerald,

What does the script look like that is attached to your buttons? Can

you post it?



Justin Klei

Cardinal Solutions Group

Avatar

Level 2
Button 1:

xfa.form.form1.SF4.acts.actsFields.actDescTitles.actDescFields.instanceManager.addInstance(true);



Button 2:

xfa.form.form1.SF4.acts.actsFields.instanceManager.addInstance(true);

Avatar

Former Community Member
Jerald_Ferguson@adobeforums.com wrote:

> Button 1:

> xfa.form.form1.SF4.acts.actsFields.actDescTitles.actDescFields.instanceManager.addInstance(true);

>

> Button 2:

> xfa.form.form1.SF4.acts.actsFields.instanceManager.addInstance(true);



Each time you click on either button, you are adding new instances of

the subforms. The statements above have no way of knowing which subform

you wish to reference. For example, the third actsFields subform would

have a som expression of xfa.form.form1.SF4.acts.actsFields[2]. In your

case, you are not using an index, so it is always referencing the first

subform.



The best way to go in this case is to use a "relative path" to get to

the subform for Button 1. Assuming you have a Button 1 inside of each

actsFields subform, you would use the following code:



this.parent.actDescTitles.actDescFields.instanceManager.addInstance(true);





Justin Klei

Cardinal Solutions

www.cardinalsolutions.com

Avatar

Level 2
Button 1:

xfa.form.form1.SF4.acts.actsFields.actDescTitles.actDescFields.instanceManager.addInstance(true);



Button 2:

xfa.form.form1.SF4.acts.actsFields.instanceManager.addInstance(true);

Avatar

Level 2
Perfect...it works great. Thanks for your help.