Expand my Community achievements bar.

Issues with creating dynamic instances

Avatar

Level 4


Good morning everyone,

I need your help again this morning on the subject of dynamic instances.

Right now I create a 'Country' instance that I want to duplicate for ever and ever.

Everything works except one little part inside that instance.

I start with a dropdown list of countries and beside that, an 'Add' button.

Inside my instance Country, I have this:

- 1 title filed set as a floating field

- 1 small table underneath that title.

First time that they open the form, by default there's a first instance. So in my 'Add button' I have code that valide if this is my first time press the button and if it is, it simply set's my floating filed equal to what they selected in my 'Country' dropdown list. It adds a '1' in my validation field for next time.

second time I go thru, I want the button to add a new instance and also populate my country label with the new choice that was just made.

This works, I see a second instance, but my code simply overwrites the country label on my first instance.

How do I write the code so that my code for updating the Country label adds the name into the right instance.

Right now, if I have 3 instances, the code will only overwrite the label in the first one. the other 2 remain nameless.

Here is what my code looks like:

var  tmpchoice=choiceCountry.rawValue;

if (tmpchoice==null){

Country1.Sub4.ff_country.rawValue=ChooseCountry.DropDownList1.rawValue;

choiceCountry.rawValue=1;

}else{

form1.MainArea2._Country1.addInstance(true); (my instance)

Country1.Sub4.ff_country.rawValue=ChooseCountry.DropDownList1.rawValue; <== issue here, don't know how to build this to take into consideration that its dynamic now.

}

Hope this is clear

Anyone got an idea how to fix this?

Thank you very much again

Patrick

1 Reply

Avatar

Level 7

xfa.resolveNode("Country1["+(Country1.instancemanager.count-1)+"]").Sub4.ff_country.rawValue = ChooseCountry.DropDownList1.rawValue;