Expand my Community achievements bar.

SOLVED

Create a new subform instance on button click

Avatar

Level 4

I need a new instance of this subform:

assessment.Page3.Standards.Standardsdetail

to be created when this button is clicked:

assessment.Page3.addanotherstandard.Button1

I tried this code on the button:

xfa.form.assessment.Page3.Standards.Standardsdetail.addInstance(

true);

but it doesn't work.

I'm a newbie and I'm trying to learn how to do all this as I go with the help of the book Creating Dynamic Forms with Adobe LiveCycle Designer, but I can't seem to figure this one out.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

On the subform that is supposed to be repeating you have to indicate that you will allow more than one. Click on the subform in the hierarchy, then on the Object/Binding tab click the checkbox that says Repeat Subform for Each Data Item.

Paul

View solution in original post

7 Replies

Avatar

Former Community Member

You need to reference the instance manager for "Standardsdetail" either explicitly

xfa.form.assessment.Page3.Standards.Standardsdetail.instanceManager.addInstance(1);

or using the underscore syntax

xfa.form.assessment.Page3.Standards._Standardsdetail.addInstance(1);

where _Standardsdetail is short for Standardsdetail.instanceManager.

Avatar

Level 4

Thank you for your quick reply. Do I need to create an instance manager somewhere, or is that built in? How do I do that?

Avatar

Former Community Member

the Instance Manager is a built in property (method/function?) of any object or subform in the form.

It's pretty cool because you can also then get details like [whatever thing is repeating].instanceManager.count to get the total number you have spawned.

Be forwarned though, if at any point you have Zero instances of the subform, the non-underscore referencing will fail. If that is a possible situation, just use the underscore syntax to directly reference the instance manager, without having to look at any specific instance.

Avatar

Level 4

I tried this both ways, and it's still not working.  I'm sure I'm missing something really basic and easy. I attached my project. I have changed the way some of the subforms are wrapped since my original post, so the names and heirarchy are a little different.

Thanks again for your help.

Avatar

Correct answer by
Former Community Member

On the subform that is supposed to be repeating you have to indicate that you will allow more than one. Click on the subform in the hierarchy, then on the Object/Binding tab click the checkbox that says Repeat Subform for Each Data Item.

Paul

Avatar

Level 4

Awesome!! It worked! I knew it was something simple like that.

Thank you so very much!

Can you possibly help with the other question I posted today about hiding everything but what the user is looking at to reduce render times?

Avatar

Former Community Member

ahh, Paul beat me to it.

it's parent subform needs to be set to Flowed content, which you have,

and the subform in question needs to be set to allow it to repeat, as he said.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----