Page 2 of 2

column displays as "undefined" when the field is blank

Posted: Thu Jan 22, 2015 3:57 pm
by Joe Sharples

Hi,

Your support is fantastic and you have helped in many different ways but I've had the same problem after there's been an update.

I have a field in the response mapped to the visibility of a component. and Javascript on the mapping.

When the response was null it didnt return anything. The code below used to work:
pre if ({ id: value } ) {
return true;
}
return false;
/pre
where 'id' was the field.

This used to work because if the _id field had no value then it would return false to the visibility, and not show the component. But since the update the service response is "undefined" which was then recognised as a value, and therefore returned true.

I now use instead:

preif (!value) {
return false;
}

else return true;/pre

This works for me now.

Is there a reason why the service returns "undefined" instead of "" when the field is null?

It used to return "undefined", then after the October update it returned "", and now after the christmas update it returns "". It seems to happen when appery do an update, which can be quite frustrating as I've had to go back and change my code.

my current code works now for when it returns "undefined". but I'm not sure if it will work if it returns "".

I don't have that much experience writing code, is there a way of writing the code that will work for both "undefined" and ""? just incase it changes again when theres another update?

Thanks,
Joe


column displays as "undefined" when the field is blank

Posted: Fri Jan 23, 2015 11:09 am
by Alena Prykhodko

Hello,

[quote:]
"undefined" instead of "" when the field is null
How can it return "" if said yourself that it is null. when translates to string type it became "undefined"
[/quote]

You can use as many comparisons as you like in your code
next code checks if value is not equal "undefined" or ""
pre
if (value !== "undefined" || !value) {
}
/pre


column displays as "undefined" when the field is blank

Posted: Fri Jan 23, 2015 12:00 pm
by Joe Sharples

Perfect
Thank you :)