How to Hide a LiveCycle Subform Instance Using addInstance in PDF Forms
Question details
The user needs to learn how to specifically target and hide an individual repeated subform instance that was dynamically generated using the addInstance method in an Adobe LiveCycle PDF form.

- Product
- PDF / Adobe LiveCycle
- Device & OS
- not provided
- Scenario
- Managing dynamic PDF form layouts by conditionally hiding specific dynamically generated subform sections without affecting other instances.
- Observed behavior
- Instead of properly hiding a single newly added subform instance, standard attempts either fail to hide the specific instance or inadvertently hide the entire parent subform structure.
Ensure your PDF form is saved as a Dynamic XML Form and that the target subform has 'Repeat Subform for Each Data Item' enabled in the Object palette.
Reference the Subform by Its Specific Instance Index
Use the instance manager to directly reference the dynamically created subform's zero-based index instead of looping through form pages or targeting the base subform name.
When you use the addInstance method, a new instance of the subform is appended to the form structure. If you simply set the presence property of the subform name to hidden, it applies globally to the entire group. To isolate the change to a single instance, you must explicitly declare its index.
Locate the exact name of your repeated subform in the Hierarchy palette within LiveCycle Designer (e.g., 'DetailSubform').
Calculate the zero-based index of the specific instance you want to hide. For the most recently added instance, use 'SubformName.instanceManager.count - 1'.
Write a JavaScript or FormCalc script to set the presence property of that exact index to hidden. For example, use: 'DetailSubform[index].presence = "hidden";'.
If you only want to hide a specific field within that specific subform instance, resolve the object reference relative to the selected instance: 'DetailSubform[index].TextField1.presence = "hidden";'.

Create and Manage PDF Forms Easily with WPS Office
While Adobe LiveCycle uses a complex, proprietary XFA architecture for dynamic forms, WPS Office provides a lightweight, highly intuitive alternative for creating, editing, and managing standard interactive PDF forms (AcroForms) without requiring complex JavaScript programming.
- 1. Open Your PDF in WPS Office: Launch WPS Office and open your standard PDF form document.
- 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available interactive form field tools.
- 3. Add Interactive Fields: Click on 'Text Field', 'Check Box', or other form controls and drag them onto your document layout.
- 4. Save and Share: Save your completed PDF form; it will remain fully compatible with standard PDF readers for easy data collection.

Frequently Asked Questions
Why does setting my subform presence to hidden affect all instances?
If you reference the subform strictly by its name (e.g., SubformName.presence = "hidden") without specifying an array index, LiveCycle applies the presence change to the entire subform group rather than an individual repeated block.
How do I find the index of the instance I just created with addInstance?
Because instances are zero-indexed, the newly created instance is typically added at the end of the collection. You can locate its index by using the formula: YourSubformName.instanceManager.count - 1.
Can I hide a specific button inside a dynamically created subform instance?
Yes. Once you have identified the specific subform instance by its index, you can drill down into its hierarchy to target the button. For example: SubformName[2].MyButton.presence = "hidden"; will hide the button only on the third instance.




