Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How to get the handle of all text fields in the subforms, using script

Avatar

Level 2
Hi Friends,

I have around 20 fields in a subform, how can i get the names of all the fields using script.



I wish to enhance the following script where the field names are hard coded

thereby the script itself will get the names of the field names.



var f1 = this.parent.somExpression + ".TextField2" + ",";

var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";

var f3 = f2 + this.parent.somExpression + ".NumericField1";

xfa.host.resetData(f3);



Any help will be greatly appreciated..



Thanks

JJ
2 Replies

Avatar

Level 10
Instead of using this.parent.somExpression (this gives you the somExpression for the container object) just use this.somExpression and that will give you the somExpression for the object.



If you want to keep your code the way it is you can also use this.name to just get the object name.

Avatar

Level 2
Hi Paul,

Thanks for your comments.

I achieved the clear contents by resetting, by taking input from your thoughts..



form1.sub1.sub2.sub3.table_1.addDelete_Top.addDelete.deleteRow::click - (JavaScript, client)

----------------------------------------------------------------------

//Here is my code finally look like..

//row 1, table_1 are also subforms

for (var i=1;i<10;i++){

var myRow = this.resolveNode("table_1.row1[" + i + "]");

if(myRow.presence == "hidden"){

i = i-1;

var myRowDelete = this.resolveNode("table_1.row1[" + i + "]");

if(i!=0){

xfa.host.resetData(myRowDelete.somExpression);

myRowDelete.presence = "hidden";

}

break;

}

if(i==9){

xfa.host.resetData(myRow.somExpression);

myRow.presence = "hidden";

break;

}

}

//----------------------------------------------------------------



Thanks

JJ