Guest User

Untitled

a guest
Jan 19th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. function processInvites() {
  2. var calendar = CalendarApp.getCalendarById("mycalendar@google.com");
  3. var now = new Date();
  4. var then = new Date(now.getTime() + (1000 * 60 * 60 * 24 * 7));
  5. var events = [];
  6.  
  7. var loopEvents = calendar.getEvents(now, then);
  8.  
  9. if(loopEvents.length > 0){
  10. for(j in loopEvents){
  11. if(loopEvents[j].getMyStatus() == CalendarApp.GuestStatus.INVITED){
  12. //if this event has no notes
  13. if(loopEvents[j].getDescription() == ""){
  14. loopEvents[j].setMyStatus(CalendarApp.GuestStatus.NO);
  15. }
  16. }
  17. }
  18. }
  19. };
  20.  
  21. function processInvites() {
  22.  
  23. var cal = CalendarApp.getCalendarById("yourcalendar@google.com"),
  24. now = Date(),
  25. then = new Date(now.getTime() + (1000 * 60 * 60 * 24 * 7));
  26.  
  27. cal.getEvents(now, then).forEach(function(event) {
  28.  
  29. if (event.getMyStatus() == CalendarApp.GuestStatus.INVITED && event.getDescription() == "") {
  30.  
  31. event.setMyStatus(CalendarApp.GuestStatus.NO);
  32.  
  33. }
  34.  
  35. });
  36.  
  37. }
  38.  
  39. // `start` < `end`; invites present in `calendar` between `start` and `end`
  40. var events = calendar.getEvents(start, end);
  41. var invitesPresent = false;
  42. for (i = 0; i < events.length; i++) {
  43. if (event.getMyStatus() == CalendarApp.GuestStatus.INVITED) {
  44. invitesPresent = true;
  45. break;
  46. }
  47. }
  48.  
  49. var invites = calendar.getEvents(start, end, {statusFilters: [CalendarApp.GuestStatus.INVITED]});
  50. if (invitesPresent) {
  51. Logger.log(invites.length > 0); // false
  52. }
Add Comment
Please, Sign In to add comment