remove event reminders/notification from generated calendar events

284 views
Skip to first unread message

Tasha Simmonds, P.A. Documents

unread,
Apr 10, 2023, 5:25:47 PM4/10/23
to Google Apps Script Community
Hi. I have a script that creates several events at once.  it's great! the only problem is I do not want my default reminders for the events I create using this method and i do not want to change or disable the reminders for other events I create.  what can I add to my script to override the default reminders?  Here is my original script: 

function createMultipleEvents() {
  const ws=SpreadsheetApp.getActiveSpreadsheet();
  const ss=ws.getActiveSheet();
  for(var i=3;i<=ss.getLastRow();i++) {
    const created = ss.getRange(i,8).getValue();
    if (created != "Event created") {}
     const eventName=ss.getRange(i,6).getValue();
     const location=ss.getRange(i,7).getValue();
     const startingDate=ss.getRange(i,3).getValue();
     var endingDate=ss.getRange(i,4).getValue();
  
   CalendarApp.createEvent(eventName,startingDate,endingDate,{location:locationsendInvites:true})
   ss.getRange(i,9).setValue("Event created")
  }
 }

function menuCreation(){
SpreadsheetApp.getUi().createMenu("Add to Calendar").addItem("Generate all events","createMultipleEvents").addToUi();
}

Ed Sambuco

unread,
Apr 11, 2023, 4:22:39 AM4/11/23
to google-apps-sc...@googlegroups.com
Not entirely sure you can do this.  You might have to use the Calendar API rather than CalendarApp.  Calendar API has a request parameter called sendUpdates that may be of use to you .. not sure.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/97e7c145-a035-4085-b11e-af8ea8b50c7cn%40googlegroups.com.

Nerio Villalobos

unread,
Apr 12, 2023, 9:00:41 AM4/12/23
to google-apps-sc...@googlegroups.com
To override the default reminders for the events you are creating using this script, you can add the setReminders method to your CalendarApp.createEvent function. The setReminders method allows you to set reminders for an event, or in your case, remove them. Here's an example of how you can modify your code:

function createMultipleEvents() {
  const ws=SpreadsheetApp.getActiveSpreadsheet();
  const ss=ws.getActiveSheet();
  for(var i=3;i<=ss.getLastRow();i++) {
    const created = ss.getRange(i,8).getValue();
    if (created != "Event created") {}
     const eventName=ss.getRange(i,6).getValue();
     const location=ss.getRange(i,7).getValue();
     const startingDate=ss.getRange(i,3).getValue();
     var endingDate=ss.getRange(i,4).getValue();
 
   CalendarApp.createEvent(eventName,startingDate,endingDate,{location:location, sendInvites:true}).setReminders([]);
   ss.getRange(i,9).setValue("Event created")
  }
 }

In this example, we are passing an empty array to the setReminders method, which removes all reminders for the event. By doing so, the default reminders will not be set for the events you are creating using this script.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/97e7c145-a035-4085-b11e-af8ea8b50c7cn%40googlegroups.com.


--
__________________________
Nerio Enrique Villalobos Morillo
Buenos Aires, Argentina

Ed Sambuco

unread,
Apr 12, 2023, 9:51:21 PM4/12/23
to google-apps-sc...@googlegroups.com
I don't know of  a setReminders() method for CalendarEvent.

Best option is to use the advanced Calendar API event.insert method (https://developers.google.com/calendar/api/v3/reference/events/insert)

You can specify reminders.useDefaults to false in the request body.  Do not specify any reminder overrides.  That will kill all reminders.

The method also has a sendUpdates parameter.  You can set that to false to kill notifications on event insert.

This looks to be a good example of needing to use the advance APIs for Calendar rather than CalenderApp.

Reply all
Reply to author
Forward
0 new messages