Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

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

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".

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Ole,

Did you check service response content in console?

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

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

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"
},
..
...
..

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

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

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

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

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.

Return to “Issues”