To add a subform instance to a form

  1. Select the object on your form design that you want to add the script to and select an event from the Show list in the Script Editor. For example, choose the click event of a button or other interactive form object.

  2. Type one of the following scripts in the Script Editor, where Subform1 is the name of the subform to add instances to, and the value true indicates that the new subform instance should be merged with the form data:

FormCalc

Subform1.instanceManager.addInstance(true) // Default instance manager syntax 
xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.

or

_Subform1.addInstance(true) // Short form of the instance manager syntax 
xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.

JavaScript

Subform1.instanceManager.addInstance(true); // Default instance manager syntax 
xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.

or

_Subform1.addInstance(true); // Short form of the instance manager syntax 
xfa.form.recalculate(true) // Invoke the recalculate method to include the field values from the added subform in the form calculations.

To remove a subform instance from a form

  1. Select the object on your form design to add the script to, and select an event from the Show list in the Script Editor.

  2. Type one of the following scripts in the Script Editor, where Subform1 is the name of the subform to remove an instance from and integer is the zero-based index number of the instance to remove:

FormCalc

Subform1.instanceManager.removeInstance(integer) // Default instance manager syntax

or

_Subform1.removeInstance(integer) // Short form of the instance manager syntax

JavaScript

Subform1.instanceManager.removeInstance(integer); // Default instance manager syntax

or

_Subform1.removeInstance(integer); // Short form of the instance manager syntax

// Ethnio survey code removed