Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: Cannot read property 'dateTime' of undefined #115

Closed
jerobins opened this issue Apr 12, 2020 · 7 comments · Fixed by #151
Closed

TypeError: Cannot read property 'dateTime' of undefined #115

jerobins opened this issue Apr 12, 2020 · 7 comments · Fixed by #151
Labels
bug Something isn't working

Comments

@jerobins
Copy link

  • Description of the problem

This just started happening with the script about a week ago. Until then, it was running normally. Now it is throwing an error for every iteration:

  • Screenshots
4/10/20 3:53 AM startSync TypeError: Cannot read property "dateTime" from undefined. (line 488, file "Helpers") time-based 4/10/20 3:53 AM
  • An input ics string that can reproduce the problem

I don't know which ICS entry is causing the error, but will share ICS link privately and reference this issue.

@jerobins jerobins added the bug Something isn't working label Apr 12, 2020
@jonas0b1011001
Copy link
Collaborator

Seems like you are running Version 5.1, i'd recommend updating to 5.2.

Does the error also occur when you sync to an empty target calendar?

@jerobins
Copy link
Author

I should add, this is with the most recent public version of the script in Google Drive. Was running an older version, updated to the most recent and tried syncing to a new Google Calendar. Got same error.

Private link to ICS file sent.

@jerobins
Copy link
Author

Yes, it is version 5.2 on Chrome V8 and triggered same error with a new empty target.

@jonas0b1011001
Copy link
Collaborator

Hi, i just got hold of your ics file.
The issue is cause by several events having an empty uid-property.

You can make it work by changing Helpers.gs lines 493-502 (Version 5.2)

var eventInstanceToPatch = calendarEvents.filter(function(item){
    var origStart = item.originalStartTime.dateTime || item.originalStartTime.date;
    var instanceStart = new ICAL.Time.fromString(origStart);

    return (instanceStart.compare(recIDStart) == 0);
  });

  if (eventInstanceToPatch.length == 0){
    Logger.log("No Instance found, skipping!");
  }

to:

  var eventInstanceToPatch = calendarEvents.filter(function(item){
    if (item.originalStartTime){
      var origStart = item.originalStartTime.dateTime || item.originalStartTime.date;
      var instanceStart = new ICAL.Time.fromString(origStart);

      return (instanceStart.compare(recIDStart) == 0);
    }
    else{
     return false; 
    }
  });

  if (eventInstanceToPatch.length == 0){
    Logger.log("No Instance found, adding as new event!");
    try{
      Calendar.Events.insert(recEvent, targetCalendarId);
    }
    catch(error){
      Logger.log(error); 
    }
  }

Let me know if it works!

@derekantrican
Copy link
Owner

We also contacted Zoho to let them know of this issue. Here is their response that I just received:

image

@derekantrican
Copy link
Owner

@jerobins did Jonas' solution work for you?

@jerobins
Copy link
Author

Unfortunately, it did not. I appreciate y'all taking a look at this. Since this really is a ZoHo issue, I'm going to punt and wait for them to fix. Thanks for a great script and for the help.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants