Avatar

Level 10

Please find my answers below.

Maybe I am not understanding the count or underscore features. From my understanding, if the "count" is 1 then the subform is visible. In that case, the user can see the question and answer it as a required field. My problem is the subform is not visible (count of 0), but can be accessed using the underscore.

Srini:

     Making a subform Visible/ hidden will be done by changing a property value similar to changing the name of the subform. That means the Subform is actually avaiable in the form Heirarchy but you set the presence property to make it Hidden/ invisible.

     As long as the subform is available in the form Heirarchy, the minimum count will be 1.

     If you do not see the subform in the Heirarchy then the count will be 0. (OR) If you delete all the subform instances by using removeInstance method then the count will become 0.

     You can access the instanceManager of the subform using a underscrore. It is a short version of accessing it.

     For example: Both the below statements are correct.

          form1.form._Q2b.presence = "visible";

          form1.form.Q2b.instanceManager.presence = "visible";

But in your simple case you mentioned, you do not need to use an Instance Manager of the subform. You just need a way to hide and display the subforms based on user input for the previous question.

     With that your code may look like this..(You donot need to use underscore notation because you are not using the Instance Manager)

    

     if (page2.mainSub.branch2.presence == "hidden"){

          page2.mainSub.branch2.reqField.mandatory = "disabled";

     }

I have a put in a sample file for your reference with the similar logic. In my example, the subforms are present in the heirarchy. I am only hiding and displaying them based on the previous answer.

https://acrobat.com/#d=LlEgTgo3**oSPJlYGxGTKw

Thanks

Srini