I was using Google calendar Clear api but nowadays I am getting following error while clearing the calendar using calendar id.
I need to clear the calendar using calendar id. I tried the same api using following url as well and getting the same error.
Calendar Id: h9tbr9nlks0p8nrkjsgbrphci4#group.calendar.google.com
I am getting following error on every calendar.
https://developers.google.com/google-apps/calendar/v3/reference/calendars/clear
message:Cannot clear primary calendar.
Just saw the reason - silly me. The documentation clearly states :
Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
https://developers.google.com/google-apps/calendar/v3/reference/calendars/clear
If you want to clear all events from the secondary calendar, you will have to loop through all of them and delete one by one.
If you really want to clear all events from the primary calendar, you need to pass 'primary' as a parameter.
Related
I am using the sample code from Google to populate vacation calendars.
It works rather well except I have recently noticed that it fails for recurring events. It throws error "Invalid iCalUID value" when trying to import a recurring or repeating event.
I believe this is due to the fact that, as per API documentation for 'iCalUID', "Note that the icalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same icalUIDs." IE. it's probably due to duplicated 'icalUIDs' or similar.
There might be some way to modify/fix by using 'recurringEventId' and/or 'id' instead or in addition to 'iCalUID' but this be beyond my current time and skills. Has anyone solved the issue with this sample code already?
I'm building a two-way script to go back and forth between Google Sheets and Google Calendar, and I'm wondering how to tell whether a CalendarEvent has been deleted.
Currently, I store event IDs in the spreadsheet every time an event is created, then I use that event ID to read/write subsequent updates to that event:
var event = eventcal.getEventById(eventId);
But I don't see a way in the documentation to determine whether a CalendarEvent has been deleted in the calendar. Retrieving a recently deleted event using the method above simply returns the CalendarEvent since it lives in the Recycle Bin. event.getLastUpdated() is also too general for me since I'd like to do different things for updated/rescheduled events and deleted events.
Use Reports API instead
When listing the Activities for a specific App you can specify the eventName and filters parameters to look for deleted events given a certain Calendar.
References
Reports API > Aplication Name
Method: activities.list
Google Calendar > Delete Event
The objective is to transfer data from Google Calendar to a Google Sheet whenever the calendar is edited. For this we need a script that transfers the data, and need to set up the Calendar trigger.
Thanks to Oleg Valter and his excellent and exhaustive explanation how to create the script on this page:
Google calendar events to Google spreadsheet automatic refresh onEdit
the data transfer already works fine when the script is started from the Google sheets. I use a modified version of Oleg's script, which works well, and I am not sure if it would make sense to re-post it here (since that is not the problem).
I have tried to create the trigger with Oleg's funtion first:
/**
* Installs Calendar trigger;
*/
function calendarTrigger() {
var trigger = ScriptApp.newTrigger('callback name here')
.forUserCalendar('calendar owners email here')
.onEventUpdated()
.create();
}
but the trigger did not fire when I have added a new event on the calendar. Checked the triggers connected to the project, and the trigger created by the above function was there. Checked the Executions and nothing showed up.
Then I have manually deleted the trigger, and manually crated a new one following the instructions under "Managing triggers manually" section of this page:
https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers
The trigger was created again, which basically looked the same as the one created by the above function, but it still did not fire when tested.
Now I am stuck and have no idea what else to try. It supposed to work, but it is possible that I have missed setting up something else that might be required for this to work.
I am using a simple Google account connected to a single email address (not a business suite). Never had any problems with the other triggers related to the sheets before that I could not resolve (sometimes the platform refuses to work as it should, but then later things get back to normal).
I would highly appreciate any advice about what else to try, or if you know what the problem is, even better.
Thanks in advance,
Zoltan
Well, after some trial and error based on ziganotschka's kind answer (thanks again) found the problem. It is caused by a bit of confusion about what the
.forUserCalendar('calendar owners email here') and the
Calendar ID supposed to be.
On my Calendar account there are several calendars, but two are of interest for us here:
"Main Calendar" which is the default calendar associated with the account. If everything else is deleted, then this will remain.
another calendar that I have added for the very purpose to be connected to the spreadsheet, and named it "Auto Billing" (only this is checked and displayed).
The Main Calendar has this on the Settings page (changed my email address):
Integrate calendar
Calendar ID
myAddress#yahoo.com
The Auto Billing calendar has this on the
Settings page (changed the ID):
Integrate calendar
Calendar ID
svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com
My intent was to use a custom created calendar for this purpose instead of using the default Main Calendar, because this might be full with all kinds of events.
Therefore when the trigger is created manually
svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com
should be added in the field "Calendar owner email" instead of the calendar owner's email address.
When the trigger is created from script using the above snippet, then
.forUserCalendar("svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com")
should be used.
In the script that transfers the data from the Calendar to the sheet the
var Calendar = CalendarApp.getCalendarById("svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com");
should be used. This way the trigger will work when events are edited on the Auto Billing calendar.
Thanks for the guidance Ziganotschka, and also big thanks to Oleg for the original script. Hope this debugging will help others as well.
Google Calendar trigger is a feature for the Google Calendar
It does not work for "myaddress#yahoo.com" calendars
I have a Google App for Business.
Is it possible to access other user's calendar to input & retrieve event?
I only know how to do it for my own calendar, but not others.
I have super administrator access.
Yes, you can get any calendar by it's ID, and then just get the events. As per your comment I don't believe that it will allow you to get any calendar in the domain, you appear to need to be subscribed. Whether this is expected or not I'm unsure.
Enter the Advanced Calendar Service, which uses the Calendar API to manage your domains calendars (and I suspect is probably the correct way to go about managing your domains calendars). After you turn the calendar service on, you can do what your looking for simply like so:
function calendar(){
var cal = Calendar.Calendars.get('calendar#domain');
Logger.log(cal.summary);
};
Which will return the 'name' of the calendar. (Note: For primary calendars, the 'name' of the calendar is almost always the same as the calendar ID).
I've read a lot of posts related to my problem... The problem is I'm not a computer programmer and it's like reading a foreign language to me. I've tried to muddle my way through it but to no avail. I've mainly been working from this post and the links from that page.
I have a Google Sheets document with a list of id numbers and a start date and end date for treatments. I'd like to be able to run a script that will auto populate a Google Calendar with the id numbers as the event title and the treatment time frame. I don't need a start and end time, I'm only looking for dates.
I would also like to create another Google Calendar from the same spreadsheet. I have 6 columns associated with each id number - a projected date and an actual date for 3 different types of testing. I would like to be able to run another script that populates a Google Calendar with the type of testing as the event title. Again, not concerned with times at all, just the dates.
I'm using this to track an experiment I'm running and it's just a lot of information to see on a spreadsheet. It would be nice easier to see all the testing I need to do in a calendar format so I don't make any more mistakes in missing testing days or when to stop treatments.
I've been trying for 3 weeks to figure this out on my own. Let's just say, I know nothing about coding...
You should try writing a function in Google Apps script.
Get the active sheet, get range and retreive the id numbers and a start date and end date.
Then create a calender event by referring to this link.
Hope that helps!