Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

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

Avatar

Former Community Member

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
Former Community Member

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
Former Community Member

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

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----