I want create an event in calendar from my custom gmail add-on. And I need to pass Title, Description to Calendar gmail add-on or google calendar.
Is it possible?
Picture of expecting feature:
You can either use the CalendarApp:
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
new Date('July 20, 1969 20:00:00 UTC'),
new Date('July 21, 1969 21:00:00 UTC'));
Logger.log('Event ID: ' + event.getId());
or Advanced Calendar Service:
function createEvent() {
var calendarId = 'primary';
var start = getRelativeDate(1, 12);
var end = getRelativeDate(1, 13);
var event = {
summary: 'Lunch Meeting',
location: 'The Deli',
description: 'To discuss our plans for the presentation next week.',
start: {
dateTime: start.toISOString()
},
end: {
dateTime: end.toISOString()
}
};
event = Calendar.Events.insert(event, calendarId);
Logger.log('Event ID: ' + event.id + ' Event link in Calendar: ' + event. htmlLink);
}
event.htmlLink lets you open the Calendar event in the UI.
And the last option is to use the create event template form which you pre-populate as described here.
Have you thought about using the Google Calendar API? You could use this to create the Calendar Event.
Other than that you will be needing to manipulate the DOM... not easy/stable.
Related
I am writing a calendar integration and using the Google Calendar api and Outlook Graph api to sync calendar events. I am receiving webhooks as changes are made to events, so it is important that events are identical across calendar providers.
When I update the event attendees on a Google event however, an event update is not sent to Outlook attendees. The result is that Outlook attendees do not have an accurate attendee list.
If I change the Title/Description/Time, Google sends an event update and the Google and Outlook events get synced (the Outlook event is updated with the correct attendee list).
I have tried updating fields the user doesn't see (ex: sequence, extended properties) in hopes that the change would trigger an event update from Google but that doesn't seem to work.
Has anyone found a way to trigger a Google event update when attendees are added or removed?
UPDATE:
For Outlook users, I create a subscription (using the graph SDK) to each user’s calendar:
var graphClient = await MicrosoftAuthenticationProvider.GetGraphClient(CALENDAR_CLIENT_ID, CALENDAR_CLIENT_SECRET, CALENDAR_REDIRECT_URI, CALENDAR_ACCESS_SCOPES, RefreshToken).ConfigureAwait(false);
var tmpSubscription = new Subscription
{
ChangeType = WEBHOOK_SUBSCRIPTION_CHANGETYPE,
NotificationUrl = WEBHOOK_NOTIFICATION_ENDPOINT,
Resource = WEBHOOK_EVENT_RESOURCE_NAME,
ExpirationDateTime = maxSubscriptionLength,
ClientState = clientState
};
var subscription = await graphClient.Subscriptions
.Request()
.AddAsync(tmpSubscription)
.ConfigureAwait(false);
When an Outlook event is updated, my webhook notification endpoint receives a notification from Outlook. This happens successfully when I edit the summary, description, start or end of an event in Google. It does not happen when I add or remove attendees.
To replicate: create an event in Google that has an attendee that uses Outlook. You will see the event in Outlook. Add another attendee to the Google event. Google does not send Outlook an update email (the way it does if the title/time/description changes). The Google and Outlook events attendees are now different.
I found a work-around:
If I know the attendees have changed, I am changing the description of the event and sending a silent patch request to Google:
var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
{
Description = Event.Description + "---attendees updated---",
};
//don't send the notification to anyone
//all attendees will get the notification when we resave the event with the original description
var patchRequest = service.Events.Patch(tmpEvent, GOOGLE_PRIMARY_CALENDARID, ExternalID);
patchRequest.SendUpdates = EventsResource.PatchRequest.SendUpdatesEnum.None;
await patchRequest.ExecuteAsync().ConfigureAwait(false);
For the patch, setting SendUpdates to None means attendees won’t receive a notification about the change, so all calendar events will be updated silently.
Finally, I save the entire event (with the proper description and attendees) and send the updates to all of the attendees:
var tmpEvent = new Google.Apis.Calendar.v3.Data.Event
{
Id = ExternalID == null ? Convert.ToString(Event.ID) : ExternalID,
Start = new EventDateTime
{
DateTime = Event.StartDate,
TimeZone = GetGoogleTimeZoneFromSystemTimeZone(timeZoneInfo.Id)
},
End = new EventDateTime
{
DateTime = Event.EndDate,
TimeZone = GetGoogleTimeZoneFromSystemTimeZone(timeZoneInfo.Id)
},
Summary = Event.Title,
Description = Event.Description,
Attendees = attendees.Select(a => new EventAttendee
{
Email = a.Value,
ResponseStatus = "accepted"
}).ToList(),
GuestsCanInviteOthers = false,
Location = Event.Location
};
var updateRequest = service.Events.Update(tmpEvent, GOOGLE_PRIMARY_CALENDARID, ExternalID);
updateRequest.SendUpdates = EventsResource.UpdateRequest.SendUpdatesEnum.All;
savedEvent = await updateRequest.ExecuteAsync().ConfigureAwait(false);
This isn't ideal because it requires two calls to Google's API just to properly save the attendees, but on the plus side, attendees are only notified of the change once.
This example of copying events doesn't work in FullCalendar v4:
https://codepen.io/ally-murray/details/JBdaBV
Does anyone know how to make this functionality in the current version?
Function "renderEvent" doesn't exist:
$calendar.fullCalendar(
"renderEvent",
{
resourceId,
title: droppedEvent.title,
start: startDate,
end: endDate },
true);
I have created one google calendar with my gmail account and I want to display that calendar in my website.
All Events related to that calender's are inserted via google calendar API using .Net Library.
It shows all events in website.but when i click on print and all events are not display in print preview.
Is there any parameter missing while calling Insert Event API?
I was having this problem with events created in a Chrome Extension. I'll spare you the code for the token, but I think it's enough that the event is created without any problems, yet refuses to print.
Desired behaviour: create event that can be printed.
Specific Error: event is created, but can not be printed.
Code:
var copyInit = {
'method': 'POST',
'async': true,
'headers': {
'Authorization': 'Bearer ' + Items.access_token,
'Content-Type': 'application/json'
},
'contentType': 'json',
'body': dataJson
};
dataJson:
"{"start":{"date":"2019-04-22"},"end":{"date":"2019-04-22"},"summary":"test"}"
API Call:
var url = 'https://www.googleapis.com/calendar/v3/calendars/' + calId + '/events?key=AIzaSyDfX9-blah9KoxzvGu3IzA1zu0oDQ-cJfw';
fetch(url, copyInit)
After much head scratching it turns out that although the Google Calendar API allows you to create all day events using the same start date and end date for all day events (using YYYY-MM-DD), such events can not be printed, and when shared will have an end date previous to the start date...
The solution is to use the following day as the end date for all day events:
"{"start":{"date":"2019-04-22"},"end":{"date":"2019-04-23"},"summary":"works!"}"
I have button with ID on the website.
At the moment we track button click with Tag Manager and Analytics.
But I would like to know, is there a way to save information about user ID and time when button was clicked?
Looking forward for any information.
Thank you!
I guess user ID, what you mentioned is internal ID in your website. First of all, you need to find a way how to receive user ID in your system. It can be many ways.
For example, let's say that your website has hidden input with user ID which has id="user-id" and you want to track button "Track this button". Basic html code if your page is:
<input type="hidden" id="user-id" value="unqieuserid123"/>
<button id="button-id">Track this button</button>
You need to create user defined variable (Variables->User-Defined Variables->New). Choose "Javascript" and enter name "UserId" and this code:
function () {
return document.getElementById("user-id") != null ?
document.getElementById("user-id").value : ""
}
At the end it should be like that:
Create variable for receiving user time (it will write user local time) with name "UserTime" and javascript code:
function() {
// Get local time as ISO string with offset at the end
var now = new Date();
var tzo = -now.getTimezoneOffset();
var dif = tzo >= 0 ? '+' : '-';
var pad = function(num) {
var norm = Math.abs(Math.floor(num));
return (norm < 10 ? '0' : '') + norm;
};
return now.getFullYear()
+ '-' + pad(now.getMonth()+1)
+ '-' + pad(now.getDate())
+ 'T' + pad(now.getHours())
+ ':' + pad(now.getMinutes())
+ ':' + pad(now.getSeconds())
+ '.' + pad(now.getMilliseconds())
+ dif + pad(tzo / 60)
+ ':' + pad(tzo % 60);
}
At the end it should be like that:
Enable built-in variable Click Element if it is not enabled yet.
Create new trigger, for your button. In my case it is like that:
Create new tag for tracking and sending data to GA. Here you can use your variables created on step #1 and #2. Like {{UserId}} and {{UserTime}}. In my example it is like that:
At the end in Google Analytics you will receive event with this label:
'user id: unqieuserid123; user time: 2017-05-31T12:20:19.06+04:00'
I solved this problem in the following way:
- Created variables in Google Tag Manager (GTM) which track the user ID and the date & time.
I already had tags which tracked button clicks on the website, so I added these variables in the categories of Tags ("Label" and "Value")
Click event
Every time user click on the button, these variables track information about ID and date&time.
I'm using eventSources method to initialize FullCalendar jQuery plugin.
eventSources: [
initEvents(visibleStartDate, visibleEndDate)
]
where initEvents is and ajax call to jsp page that returns json object representing events to be rendered. It works great but now I'd like to fetch the event only for the dates visible on calendar. I read in documentation that I could use visStart and visEnd on View object to get the start and end day of the calendar, however I don't know how to get that information at the time I initialize my eventSources. Is there a way? Thank you in advance for your responses.
Eric
It turns out that fullcalendar plugin will add start and end HTTP parameters when calendar sources are fetched externally. Full details are described in documentation here: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/
My code (mix of javascript, JSP, JSF):
FullCalendal initialization:
page.view.calendar.fullCalendar(
{
....
eventSources: [
page.control.initEventSources(#{sessionBean.myCalendar.calendarConfgIdNbr},'Approved'),
page.control.initCalendarHolidays(#{sessionBean.myCalendar.calendarConfgIdNbr})],
....
});
2. My javascript function:
page.control.initEventSources:
var page = {
control : {
initEventSources : function(calConfId, status) {
return {
url: '/oceportal/tom/data/bookings.jsp',
type: 'POST',
data: { calConfId: calConfId, bookingStatus: status, loggedInId: "#{sessionBean.loggedInId}", },
success: function(data) { },
error: function() { alert('there was an error while fetching events!'); },
color: 'none',
textColor: page.colorConfig[status]
};
}
}
}
My JSP snippet (to retrieve first and last visible day):
String start = request.getParameter("start");
Date startDt = new Date(Long.parseLong(start)*1000);
String end = request.getParameter("end");
Date endDt = new Date(Long.parseLong(end)*1000);
Hope it helps someone.