1

I want log the data in device.calendar.ongoing so I can debug a problem with my script. I have tried

if (device.calendar.ongoing.length > 0) {
    console.log("All items: " + JSON.stringify(device.calendar.ongoing));
}

but that returned

All items: [{}]

When I did

if (device.calendar.ongoing.length > 0) {
    console.log("All items: " + device.calendar.ongoing);
}

But that returned

All items: 0

Any ideas on what I am doing wrong?

Mike Wills
  • 20,959
  • 28
  • 93
  • 149
  • Are you sure anything is inside of "device.calendar.ongoing"? – Ian Aug 22 '12 at 15:37
  • Yes, this is all wrapped in an if length > 0 statement. I have updated my post to reflect that. – Mike Wills Aug 22 '12 at 15:40
  • Well, it doesn't matter if "device.calendar.ongoing" has an empty object inside, it still has a length of > 0. Look at this: http://jsfiddle.net/hsCny/ – Ian Aug 22 '12 at 16:30
  • From what i saw over here https://www.onx.ms/#apiPage/calendar , `ongoing` - returns appointments that started before the current time and end after it. Do you have any appointments that meet these criterias? – Filipe Batista Aug 22 '12 at 16:43
  • I am running this during an appointment. – Mike Wills Aug 22 '12 at 17:01
  • Looks like the root cause of my questions might be due to a bug in on{x}. – Mike Wills Aug 23 '12 at 14:25

1 Answers1

2

for an unknown reason stringify doen't always work with on{x}. I use

var events = device.calendar.ongoing;
for(var i=0;i<events.length;i++) {
    console.log(events[i].title+": "+events[i].description);
}

this works in my cases.

Bastian Rang
  • 2,137
  • 1
  • 19
  • 25