Skip to content
Advertisement

How to change title of an event?

I am trying to update the title of the events in the last 7 days in a specific calendar, when an user submits a form.

I have this code now:

JavaScript

However, I get that error when running the code: TypeError: events.setTitle is not a function myFunction @ update.gs:22

I tried many different ways of doing it, but it always ends with an error. Could you please tell me what I am doing wrong?

Thank you very much for your help!

Advertisement

Answer

From your showing script, getEvents(startTime, endTime) returns CalendarEvent[]. And setTitle(title) is a method of Class CalendarEvent. In your script, at events.setTitle('Returned'), setTitle is used to an array. I think that the reason of your issue is due to this. When you want to change all events in events with setTitle('Returned'), how about the following modification?

From:

JavaScript

To:

JavaScript
  • By this modification, the title of all events in events are changed.

References:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement