Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Making Subform Instances Visible/Invisible

Avatar

Level 2

Hello,

      I am trying to loop through the Subform Instances of the form and trying to make them visible/invisible on the click of a Check Box. The script seem to run just fine but the values nothing happens to the subforms. The script is written on the CLICK event of check box and is as below:-

----- HAP_DOCUMENT.APR.HAP_DOCUMENT.Positions.DATA.CHECK_BOX::click: - (JavaScript, both) ----------

var

nCount = APR.HAP_DOCUMENT.T_ELEMENTS.DATA.instanceManager.count;

//var plan_value = this.parent.PLANS.rawValue;

var

plan_value = this.parent.parent.parent.Storage_Form.PLANS.rawValue;

for (var nItem = 0; nItem < nCount; nItem++) { // Begin Loop T_ELEMENTS after the Instance is created

var sub_Tele = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"]";

var tName = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"].T_COLL_CELL.DATA";

var sCount = xfa.resolveNode(tName).instanceManager.count;

for (var sItem = 0; sItem < sCount; sItem++) { // Second Loop on T_COLL_CELL

var fName = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"].T_COLL_CELL.DATA["+ sItem +"].T_FIELD.DATA";

var tCount = xfa.resolveNode(fName).instanceManager.count;

for (aItem = 0; aItem < tCount; aItem++){ // Third Loop on T_FIELD

var gName = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"].T_COLL_CELL.DATA["+ sItem +"].T_FIELD.DATA["+ aItem +"].simpleField.VALUE_STRING";

var lName = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"].T_COLL_CELL.DATA["+ sItem +"].T_FIELD.DATA["+ aItem +"].simpleField.CAPTION";

var subName = "HAP_DOCUMENT.T_ELEMENTS.DATA["+ nItem +"].T_COLL_CELL.DATA["+ sItem +"].T_FIELD.DATA["+ aItem +"]";

var aVal = xfa.resolveNode(gName).rawValue;

var bVal = xfa.resolveNode(lName).rawValue;

var subVal = xfa.resolveNode(subName).presence;

if (bVal == "Position Number"){

if (aVal == plan_value) {

if ( this.rawValue == 1) {

xfa.resolveNode(subName).presence

= "visible";

}

else {

xfa.resolveNode(subName).presence

= "hidden";

}

}

}

}

}

}

Is there any other way of addressing the properties of the Subform Instances? Could any please help me as to why there is no effect on the subforms?

Regards,

Shishir.P

1 Reply

Avatar

Former Community Member

Is the form saved as dynamic? Are you getting any errors in the javascript console?

Paul