Expand my Community achievements bar.

SOLVED

Another Null Concatenated field question

Avatar

Level 3

I am having some difficulty returning values checked for null.

The Javascript function is Calculate and my code is as follows:

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue + " ");
} else {

}
+
if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue + " ");
} else {

}
+
if (xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue + " - ");
} else {

}
+
if (xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue);
} else {

}

The initial value is not null returns properly, however, any subsequent value will override previous values and return the last not null field value.

Please help...

1 Accepted Solution

Avatar

Correct answer by
Level 10

Try the following code.. See if it helps.

var strVehicleYear, strVehicleMake, strVehicleModel, strVehicleColour

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue != null)

strVehicleYear = xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue + " ";

else

strVehicleYear = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue != null)

strVehicleMake = xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue + " ";

else

strVehicleMake = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue != null)

strVehicleModel = xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue + "-";

else

strVehicleModel = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue != null)

strVehicleColour = xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue;

else

strVehicleColour = "";

this.rawValue = strVehicleYear + strVehicleMake + strVehicleModel + strVehicleColour;

Thanks

Srini

View solution in original post

4 Replies

Avatar

Level 3

Nope, and I was wrong with the "+" signs as when they are there no values are returned.

Without the "+" signs as follows:

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue + " ");
} else {

}

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue + " ");
} else {

}

if (xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue + " - ");
} else {

}

if (xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue != null) {
(xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue);
} else {

}

I don't then get the "Null" value within the concatenated field, however, only the last value which is not null shows in this field.

How do I attach all the fields together?

Avatar

Correct answer by
Level 10

Try the following code.. See if it helps.

var strVehicleYear, strVehicleMake, strVehicleModel, strVehicleColour

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue != null)

strVehicleYear = xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Year").rawValue + " ";

else

strVehicleYear = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue != null)

strVehicleMake = xfa.resolveNode("INPUT.Vehicle.Row[0].Vehicle-Make").rawValue + " ";

else

strVehicleMake = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue != null)

strVehicleModel = xfa.resolveNode("INPUT.Vehicle.Row[1].Vehicle-Model").rawValue + "-";

else

strVehicleModel = "";

if (xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue != null)

strVehicleColour = xfa.resolveNode("INPUT.Vehicle.Row[2].Vehicle-Colour").rawValue;

else

strVehicleColour = "";

this.rawValue = strVehicleYear + strVehicleMake + strVehicleModel + strVehicleColour;

Thanks

Srini