Expand my Community achievements bar.

SOLVED

Number of new instances not showing in repeating sub-form...

Avatar

Level 3

Hello

Firstly thank you so much to these forums.  They save my life so often.  Hoping someone can do the same with this issue I have - its' a bit complicated!

I have a form which outlines a number of account types (Individual, Joint, Company etc) which are all individual subforms.  Within the Joint and Company subforms you need to indicate how many holders / directors there are by entering a figure which in turn produces a table with that amount of rows for completion of their names.  The code I used for this is in the click event of a button:

*txtCorpNum being the field you enter the number in - within a subform called sfDetail*

*form1.Main.sfCorp.tblCorpName being the subform the resulting table is contained in - which is hidden until the button is clicked*

this.resolveNode"(form1.Main.sfCorp.tblCorpNum").presence = "visible"';

var v_rows = this.parent.txtCorpNum.raw.value

form1.Main.sfCorp.tblCorpName.Row1.instanceManager.setInstances (v_rows);

This works wonderfully for all account types that require it - but if a person has multiple account types, they need an option to ADD another account.  So I have wrapped ALL the subforms for the separate account types into ANOTHER subform called "Account" and clicking will add a new instance of ACCOUNT containing all the types to choose from again.  Again all working like a charm, but the one thing I cannot get to feed through is the repeating table.

Can anyone tell me how I can reference the number to replicate in the new "Account" subform?  If I choose the same account type in the new subform it adds to the original subform, not the repeated one.

Probably makes no sense but hopefully someone can help

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi, I think the easy way you may try is to reference your objects starting with subform you're in. So instead of form1.Main.sfCorp.tblCorpName.Row1.instanceManager.setInstances try sfCorp.tblCorpName.Row1.instanceManager.setInstances.

Also, just sharing my experience, for the scenarios like you describe it's easier to just code the button within your multiple instances table that would add a row (or set of fields). That way user can manipulate the instances number easier. And you probably want to have the button to remove the individual instance as well.

Hope it helps.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 2

Hi, I think the easy way you may try is to reference your objects starting with subform you're in. So instead of form1.Main.sfCorp.tblCorpName.Row1.instanceManager.setInstances try sfCorp.tblCorpName.Row1.instanceManager.setInstances.

Also, just sharing my experience, for the scenarios like you describe it's easier to just code the button within your multiple instances table that would add a row (or set of fields). That way user can manipulate the instances number easier. And you probably want to have the button to remove the individual instance as well.

Hope it helps.

Avatar

Level 3

You - my friend - are a SUPER HERO!  That worked.  Simple as that.  I am totally self taught on this stuff, so I have always been of the idea that it was better to reference more than less when there was multiple sub-forms.  Clearly I am totally wrong there!!

I don't suppose you can explain that concept to me can you?

Thank you SO SO SO much....

Avatar

Level 2

Hi again and thank you so much for your kind words. I wish I could give you a meaningful explanation, but unfortunately I can't, because I was also learning this stuff by browsing through forums and asking for support from knowlegeable users

I think there's some referencing rules, which you can investigate on the JavaScript DOM subject, which may bring more light for you on this concept.

Otherwise, let me know if there's anything else I could help you with