How to send E-MAIL to organizers in Google Calendar - google-apps-script

I need send e-mail to the organizers of a event in Google Calendar, think in that situation of a video conference meeting : A person create a event and set a location for it, but one of the guests that are in another place set a location too, and we have rules for the locations that need to be sent by email to the organizer of the event and for that guest that included the new location if that's the case. The problem is, how can I know the user that edited that location?
I have another question too, how can i get the last event that has been created on a calendar?

how i can know the user that edited that location ?
You cant unless you set up push notifications doc
How can i get the last event that has been created on a calendar?
events.list has an order by parameter that lets you sort by the start time or by the updated.

Related

Open Google Calendar Via Sheets and Allow user to create Entry with info from Sheet

I have a sheet and I want the user to enter some details like a Name and Location. I then want to to press a button which will launch Google Calendar and allow them to create a entry that will add the Name and Location details and then send the Date and Time of the event back to sheets.
I have looked everywhere for code for this but can only find creating an event in the calendar if the date and time are set in the sheet already.
Is this even possible?

Google Calendar API — htmlLink property of the Event does not work properly when logged in with multiple accounts

I would like to display the link to the Calendar Event. I get the link from the Google Calendar API as part of the Event object — htmlLink property.
The problem happens when the user meets the following conditions:
They are logged in via multiple Google accounts (say, Private and Work)
The primary account does not match the one who has access to the Calendar in question
What happens next:
When the mentioned user clicks the link, they are taken to the Calendar of their primary account instead of the calendar that is associated with the event. This naturally results in permissions error.
When the user copies the URL, then goes to their calendar, then switches their account to the secondary account and insert the URL manually, then it works.
Do you guys know of a user-friendly way to mitigate this problem?
I've just found out:
In API we get htmlLink like
https://www.google.com/calendar/event?eid=[\w+]
Modify it into:
https://calendar.google.com/calendar/event?action=VIEW&eid=[\w+]
The new link leads different users to different pages:
For users logged in, location is redirected into their own calendar page, and a popup inside the webpage appears to show event information.
For clients not logged in with any Google account, there would be no redirections and a traditional page is shown.
For example: https://calendar.google.com/calendar/event?action=VIEW&eid=OGxnZ2loODc5YWU0NzM5aGc1YWtkZmxsZzhfMjAyMjEwMjlUMDUzMDAwWiB0YWl3YW5oYW5kam9iQG0
And for those who do not use Google API but want a link to an individual event:
use publish event function in the event menu to get an URL with eid, and then modify the URL manually.

Communicating between Google Calendar, Google Forms and Google Spreadsheets

Consider a Google Calendar scenario with various rooms that can be booked. Users will be browsing the different rooms and can create an entry in one of the free slots. The basic default properties provided by the Google Calendar are not sufficient for the business scenario but I haven't found a way to add more fields: the default new event form does seem to be customisable. Is this so?
My idea was to provide a Google Form to cover the rest of the details.
The process would look as below:
The user browses the different rooms and finds an available slot. The calendar entry is created with the basic details. The entry is added into the calendar and the details are recorded into a Google spreadsheet.
The user receives an email with another google form: the ID of the appointment would need to somehow be passed as parameter. The google form will be used to insert the "advanced details" into the spreadsheet.
An interface will be created to view the spreadsheet data in a more structured and user friendly manner.
Can something like this be done using Google Calendars, Google Forms and App Script? Any pointers where to start from? Or if not, how the process could be changed to be actually possible. The only starting points I found were Add ins which create calendar entries directly from Google forms, but this would require the user to start from a form, rather from the calendar, which I would not rather go for, not at least until I know there's no other way.

GAS - Access Other User's Calendar ID

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).

Possible to create event using Google CalendarApp and send to somebody else?

I have written a script that queues reminders, and emails them a delegated user. I would like to send calendar events to the person, instead of emails.
My question is: Is it possible to create an event using the CalendarApp and send it to another gCalendar user? I see API's for querying ownership, but not for setting it. An event with anonymous ownership would also be useful.
There are two approaches here.
You can setup your script so that it is runs as the user who will want the calendar invite. You can see this under the Publish menu option
OR you can add the person as a guest using the addGuest API.
There are no other ways to access another person's calendar and adding an event owned by them. Sounds the given the current setup #2 would be the simplest.