I am fetching events from google calendar using getEvents(startTime, endTime) method. https://developers.google.com/apps-script/reference/calendar/calendar#getEvents(Date,Date) According to this documentation on Google, we can pass the timezone in which we are sending start & end date but how? That is not mentioned . So how can we pass timezone while fetching events from Google Calendar using method getEvents(startTime, endTime) in apps-script
The Date type handles timezones; see more informations here : https://developers.google.com/google-ads/scripts/docs/features/dates
You can use for example getTimezoneOffset() to retrieve the timezone of a given Date.
Related
I was trying to import Google calendar all the appointment slots and put them in the Google Sheet using Google CalendarApp Script. But when I am fetching all the events, it returns every event except for the Appointment Slots from the calendar.
Does anybody know, how to fetch these types of things from the calendar, which is apparently not an Event ?
At the moment, this is not possible - you cannot retrieve appointment slots data using the Google Calendar API.
There is a feature request submitted into Google's Public Issue Tracker. To know about its status, I suggest you visit the following link: https://issuetracker.google.com/issues/36757162
I'm trying to create events from a sheet of a column of dates and a column of data.
I'm getting hung up on this error message:
Cannot find method createAllDayEventSeries(string,string,string). (line 14, file "Code")
My code is attached in the screenshot, and for the most part I followed the Gsuite tutorial online, even though I used allday event code as I do not have times in my sheet.
Any clue as to where I'm going wrong?
The problem is that the parameters are of the wrong type. According to https://developers.google.com/apps-script/reference/calendar/calendar#createalldayeventseriestitle,-startdate,-recurrence
Parameters
Name Type Description
title String the title of the events in the series
startDate Date the date of the first event in the series (only the day is used; the time is ignored)
recurrence EventRecurrence the recurrence settings of the event series
but you script is passing all the parameters as Strings
Related
Create Google Calendar Recurring Events from Spreadsheet
Creating recurring Google Calendar events from Google Sheet
Create Recurring All Day Calendar Event from List of Dates in Google Sheet
How can you set the current time with google app scripts? I'm having a tough time finding the Time documentation.
I'm able to get the time in milliseconds using.
(new Date()).getTime()
I'd like to now format this time as 11:56 AM. I'm using the Date documentation. I've tried using toLocaleTimeString() from javascript but it is not defined in app scripts
For formatting a date, what you want is the Utilities.formatDate() function, documented here: https://developers.google.com/apps-script/reference/utilities/utilities#formatDate(Date,String,String)
Usage to get the time only would be:
Utilities.formatDate(YOUR DATE,YOUR TIMEZONE, 'HH:mm')
replacing YOUR DATE and YOUR TIMEZONE with the appropriate values.
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'm working on a spreadsheet in Google Drive to keep track of when we need to get our employees their annual reviews. As part of the calculations, I need to be able to compute their anniversary dates by adding years to their start dates. I'm trying this:
returnDate = returnDate.setYear( returnDate.getYear() + 1);
Alas, the scripting language that google supports seems to lack many of the useful functions of a fully-fledged Javascript Date object, as I get this error on that line when I try to run it:
TypeError: Cannot find function setYear in object 1357106400000. (line 28, file "Code")
So, how can one compute a series of anniversary dates using the tools available in Google Apps Script?
Thanks for any help.
Works like this :
function addOneYear(y){
var fullYear = y.getFullYear();
return new Date(y.setFullYear(fullYear+1));
}
According to Javascript specifications here getYear and setYear are not recommended