Skip to content

Commit

Permalink
Validate color property prior adding
Browse files Browse the repository at this point in the history
As discussed in #308
  • Loading branch information
jonas0b1011001 committed Sep 27, 2023
1 parent e5cd8e0 commit 95fa37c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Helpers.gs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,12 @@ function createEvent(event, calendarTz){
}

if (event.hasProperty('color')){
newEvent.colorId = event.getFirstPropertyValue('color').toString();
let colorID = event.getFirstPropertyValue('color').toString();
if (Object.keys(CalendarApp.EventColor).includes(colorID)){
newEvent.colorId = CalendarApp.EventColor[colorID];
}else if(Object.values(CalendarApp.EventColor).includes(colorID)){
newEvent.colorId = colorID;
}; //else unsupported value
}

return newEvent;
Expand Down

0 comments on commit 95fa37c

Please sign in to comment.