Reputation: 39
I've got a problem to change the color in an All Day Event in google calendar with google apps script. I tested a lot of way to go, but nothing works.
var event = CalendarApp.getCalendarById(calendrierId).createAllDayEvent(title,date).addPopupReminder(1440);
Does anyone has a solution
Thanks
Upvotes: 1
Views: 2267
Reputation:
You need to use the Advanced Calendar Service (That must be enabled before use. In the Script Editor select Resources > Advanced Google services... and then enable it in the Google Developers Console.)
Once enabled you can create an event using the Events: insert and use colorId to set the color of the event, here's an example:
function myFunction() {
var calendarId = '{YOUR_CALENDAR_ID}';
var date = "2016-12-25";
var event = {
summary: 'Christmas Day',
location: 'Home',
start: {
date: date
},
end: {
date: date
},
// Bold Red background.
colorId: 11
};
Calendar.Events.insert(event, calendarId);
}
As of today, there are 11 colors available for events, you can use Calendar.Colors.get() for the full list, but here's a table with the names used in the UI that you're probably more familiar with:
| name | colorId | background |
|------------|---------|------------|
| Blue | 1 | #a4bdfc |
| Turquoise | 2 | #7ae7bf |
| Purple | 3 | #dbadff |
| Red | 4 | #ff887c |
| Yellow | 5 | #fbd75b |
| Orange | 6 | #ffb878 |
| Turquoise | 7 | #46d6db |
| Gray | 8 | #e1e1e1 |
| Bold Blue | 9 | #5484ed |
| Bold Green | 10 | #51b749 |
| Bold Red | 11 | #dc2127 |
Upvotes: 2