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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

Using string to designate a subform for the instanceManager


Level 7

var propOptSubformID     = "8011"

var propSubformName     = Concat("SubformPropOption",propOptSubformID,".instanceManager")      //since instanceManager is object


I get:


I can't seem to find a way to use the instanceManager and successfully reference a subform using a string. Any ideas?

I want to avoid using conditional statements or switch if possible. I have 35 different subforms eachl with 0 instances. I want to identify one of the subforms using a variable (string) and make it exist. There has to be a way to do this, right?

I may have to name all the subforms the same and use an index--but I would like to avoid that, Or, I suppose I could loop through the siblings and compare my string to the subform name--but I think this might end up having the same problem. It would be really good to know how to do it with a string and the instanceManager..



PS, I also tried

var propSubformName     = Concat("SubformPropOption",propOptSubformID,".instanceManager.setInstances(1)")


and...  Nothing happens? No error and no subform either?

4 Replies


Level 10



Level 7

Thanks Robert,

I might be missing something--I've never seen square brackets used in the way you suggest. Am I missing something?

The subform doesn't have an index[propOptSubformID]  It would have an index[0] when it actually does exist. This isn't really an index problem. That would be easy and I think I may have to go that way (i.e. name them alll the same and reference them by index) if I can't reference the object.instanceManager and use its method setInstances() with a string.

This might be a clue: the error message referred to setInstances() as a property--it is a method(). If it had recognized it as a method, then it the error would have said that the object doesen't have a method setInstances(). Also, it represented the ("1") as a string when it an integer parameter for setInstances().



Level 10


the instanceManager property cannot be part of a SOM expression, that's why your script fails.

Use this script instead:

var propOptSubformID     = "8011"

xfa.resolveNode("SubformPropOption" + propOptSubformID).instanceManager.setInstances("1");


Level 7

Hi Radzmar,

I ran your JS script (added a semicolon at the end of 1st line) and got:

Exception in line 2 of function top_level, script XFA:form1[0]:SubformBody[0]:SubformLocation[0]:SubformPropCrDb[0]:DdlPropCreditDesc[0]:exit

Also, tried the same without the quotes ("1") with same result

Any idea whats going on?

Message was edited by: kingphysh