Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

instanceManager Question

Avatar

14-07-2008

Hi,



Wondered if anyone has run into this. Basically I am trying to programatically add instances of a repeating subform. The trick is I don't want the subform visible to begin with, (min count = 0). Apparently it is not as simple as:



Item.instanceManager.addInstance(1);



Which works when the min count = 1. Any ideas on how I can code to add instances to a repeating subform that starts out with a min count = 0?



Any help would be appreciated.



Thanks



Ken

Replies

Avatar

Avatar
Level 5
_SekharN_
Level 5

Likes

0 likes

Total Posts

246 posts

Correct Reply

0 solutions
View profile

Avatar
Level 5
_SekharN_
Level 5

Likes

0 likes

Total Posts

246 posts

Correct Reply

0 solutions
View profile
_SekharN_
Level 5

14-07-2008

try the following....



//Invoke the Instance Manager to add one instance of the detail subform.

_Item.addInstance(1);//where "Item" is the subform Name



//Invoke the recalculate method to include the field values from the added subform in calculations.

xfa.form.recalculate(1);

Avatar

14-07-2008

SekharN,



Thanks for the timely reply.



What I seem to run into is that when the min count = 0 my efforts to refer to the subform "Item" within my code result in an error message indicating that "Item" isn't defined.



How do I refer to the subform initially?



Ken

Avatar

Avatar
Level 5
_SekharN_
Level 5

Likes

0 likes

Total Posts

246 posts

Correct Reply

0 solutions
View profile

Avatar
Level 5
_SekharN_
Level 5

Likes

0 likes

Total Posts

246 posts

Correct Reply

0 solutions
View profile
_SekharN_
Level 5

14-07-2008

Unknown whether you selected "Repeat Subform for Each Data Item" under subform Binding tab. You can check that and leave "Min Count:, Max: and Initial Count:" unchecked. Then you will not run into such problem.<br />again the syntax for add instance is:<br />"_<subformname>.addInstace(1)" //"_" (Underscore) is a reference notation not part of the subform name.<br /><br />If you still can not over come the issue I can offer help at "meetsekharv AT yahoo.com"

Avatar

15-07-2008

SekharN,



Sorry, I don't mean to be a pest. Here is some additional info:



I reduced my test form to the bare essentials. I have one main subform called Main that contains a sub form called Sub1. Main is defined as flowed and Sub1 is positioned with "Repeat for all data" checked (This time I left the min, max, and initial counts unchecked.



I have one button for adding and instance located in Main. The code behind the button is exactly as follows:



var oSubform = this.resolveNode("Main.Sub1");

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

xfa.form.recalculate(1);



This results in an error that indicates my subform reference has no properties. When I switch to min count = 1 the button adds a new instance of the subform, (but as you may recall my objective is to not have an initial instance of the subform visible or taking up room which is why I am attempting to do this without a min count = 1).



Using an "_" in front of the sub form name as follows:



_Sub1.instanceManager.addInstance(1);

xfa.form.recalculate(1);



I receive an error message that reads "General Error: Operation Failed".



If this is supposed to work could it be the version of LiveCycle Designer I am using?

Avatar

15-07-2008

My appologies. I re-read your previous reply and double checked my code and realized that I had incorrectly used the _Sub1.instanceManager.addInstance(1);



rather then _Sub1.addInstance(1);



It seems to be working now.



Many thanks!