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

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
Adobe Summit 2023 | Complete list of AEM Sessions & Labs
SOLVED

i have numerous text fields which are data binded , i need to concatinate them

Avatar

Not applicable

Hi i

have numerous text fields data binded, which i have to concatinate all  of them to show on a particaular section, the thing is if the data field is null, the then it should not be shown, i mean if the data field is has nothing i get a null

my code is as follows:

this.rawValue

= xfa.resolveNode("Page7.pre_pri_sec_1").rawValue+ " " + xfa.resolveNode("Page7.pre_pri_sec_2").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_3").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_4").rawValue

+

" " +xfa.resolveNode("Page7.pre_pri_sec_5").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_6").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_7").rawValue

+

" " +xfa.resolveNode("Page7.pre_pri__sec_8").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_9").rawValue+" " +xfa.resolveNode("Page7.pre_pri_sec_10").rawValue  etc...;

so if some of the fields has no value then it is shoing as "null", how do i get rid of this null,..? and if any field has no value then there is a space left over for it.

can somebody help me on this..

Thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 10

You will have to check for nulls on each field. For example, you could add the following to the calculate event of the target fiield

// form1.Page7.resultStr::calculate - (JavaScript, client)


var str = "";


if (Page7.pre_pri_sec_1.isNull) {

  str = str;

}

else {

  str = Page7.pre_pri_sec_1.rawValue;

}


if (Page7.pre_pri_sec_2.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_2.rawValue;

}


if (Page7.pre_pri_sec_3.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_3.rawValue;

}


.....


if (Page7.pre_pri_sec_10.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_10.rawValue;

}


this.rawValue = str;

Steve

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You will have to check for nulls on each field. For example, you could add the following to the calculate event of the target fiield

// form1.Page7.resultStr::calculate - (JavaScript, client)


var str = "";


if (Page7.pre_pri_sec_1.isNull) {

  str = str;

}

else {

  str = Page7.pre_pri_sec_1.rawValue;

}


if (Page7.pre_pri_sec_2.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_2.rawValue;

}


if (Page7.pre_pri_sec_3.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_3.rawValue;

}


.....


if (Page7.pre_pri_sec_10.isNull) {

  str = str + "";

}

else {

  str = str + " " + Page7.pre_pri_sec_10.rawValue;

}


this.rawValue = str;

Steve