Page 1 of 1

Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 10:47 am
by Ole Henrik Oftedal

Hi!

This happened to my App after last Appery update some hours ago.

I have several services connected to my app. When no data (no JSON pair) is returned from the service, I get undefined values instead of my usual blank/empty ones. Is this a know problem? Example:

Image

The component in use here is of type "Label".


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 11:20 am
by Kateryna Grynko

Hi Ole,

Did you check service response content in console?


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 11:33 am
by Ole Henrik Oftedal

I'm not sure how you do that. Is that in Firebug?

I did use the the builder Test button on the service. And It runs just fine. See JSON data below.

("FrKode" in norwegian (see picture above) means Absence code or AbsCode as you can see in the JSON data underneath. Dag=Day, Data=SummaryColDay)

{
"result":[
{
"SummaryColTotal":"49.57",
"TimeSheetLocked":"0",
"Data":[
{
"Day":"1",
"ClockingsSummary":"02.00-18.00",
"SummaryColDay":"6.00"
},
{
"Day":"2",
"ClockingsSummary":"08.40-16.00",
"SummaryColDay":"-0.40"
},
{
"Day":"3",
"ClockingsSummary":"18.12-20.16",
"SummaryColDay":"2.04"
},
{
"Day":"4"
},
{
"Day":"5",
"AbsCode":"FML"
},
..
...
..


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 12:01 pm
by Kateryna Grynko

Ole,

Yeah, maybe after the upgrade, such responses from the service are now handled differently. Usually the response format is strictly regulated and can not be changed just because there is nothing to display.

If this response is returned then you can tidy and put in order the returned data.


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 12:11 pm
by Ole Henrik Oftedal

can you explain "If this response is returned then you can tidy and put in order the returned data.". This is already very tidy data and also put in order.


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 2:18 pm
by Kateryna Grynko

Ole,

Your answer is not strictly structured, you're missing a field in the response if they are empty or have default values​​. This is not correct from the point of view of a standard response. Platform code expects that all of the response fields comes with each successful answer. The platform is simply not prepared for the fact that some of the fields will be thrown out the response.


Displays "undefined" when no data is returned from service.

Posted: Fri Aug 23, 2013 2:35 pm
by Ole Henrik Oftedal

Ok, I understand. To bad. This way more data has to be transferred. I can also use javascript to check if undefined but then this could slow the the app a little bit because code has to be run on every line of data.