Referencing unnamed and repeated objects

Designer supports the capability to create both unnamed objects and multiple objects with the same name. You can still create calculations and scripts to access and modify properties and values of unnamed objects by using the number sign (#) notation and object occurrence values using the square bracket ([ ]) notation. FormCalc correctly interprets the number sign (#) and square bracket ([ ]) characters; however, JavaScript does not. To access the value of a text field in a situation where the number sign (#) or square brackets ([ ]) occur, using JavaScript, you must use the resolveNode method in conjunction with either a fully qualified reference syntax or an abbreviated reference syntax.

For example, when you create a new blank form, by default, the name of the subform that represents the page of the form is an unnamed subform with an occurrence value of 0. The following illustration shows the form hierarchy on a new form with default object naming.

The untitled subform that represents the first page of the form has an occurrence number of 0. In this situation, both of the following reference syntaxes access the value of the text field in the form hierarchy above on a new form that uses default naming conditions:

Note: By default, if you do not specify an occurrence value for an object, the reference syntax accesses the first occurrence of that object.

FormCalc recognizes the fully qualified reference syntax above and interprets it directly. To access the same value by using JavaScript, you must use one of these forms of the resolveNode scripting method:


If you add a new page to your form, by default, the name of the subform that represents the new page is unnamed; however, the occurrence value for the new subform is set to 1. You can specify the new unnamed subform by using a similar reference syntax as above:

    xfa.form.form1.#subform[1].TextField1.rawValue // FormCalc 
    xfa.resolveNode("xfa.form.form1.#subform[1].TextField1").rawValue; // JavaScript
Note: The statement completion options available in the Script Editor include unnamed objects at the beginning of the list. Objects that have multiple occurrence values appear only once in the list, representing the first occurrence of the object. If you want to access an occurrence value other that the first occurrence, you must manually add the occurrence value to the reference syntax.

You can use the resolveNode method to reference objects within other reference syntax statements. This can help to reduce the amount of scripting you need to reference a particular object, property, or method. For example, you could simplify the reference syntax that points to a text field on the second page of your form to the following statement:

    xfa.form.form1.resolveNode("#subform[1].TextField1").rawValue; // JavaScript

For more information on the resolveNode method, see resolveNode.

// Ethnio survey code removed