Create Calendar Event depending on RSVP answer in Form

32 views
Skip to first unread message

p

unread,
Mar 20, 2019, 10:56:05 AM3/20/19
to Google Apps Script Community
Hello:

Total newbie here.  I am trying to get this simple script to add an event to a responder's calendar.  The script works if I delete the elseif's, but throws an error "missing ; before statement" when I add them back in.  Can anyone help?

Thanks,

P

function rsvpEvent(e){
    var form = FormApp.openById("1NIzHwbHTAJcot7o5sUMR_pmY9hzV65iNu1m4k-6ruko");
    var formResponse = e.response;
    var itemResponses = formResponse.getItemResponses();
    var email = itemResponses[0].getResponse();
    var guest = itemResponses[7].getResponse();
  
    if (guest == "Yes, I do plan to attend alone.") {var newEvent = CalendarApp.getDefaultCalendar().createEvent("Annual Service Awards", new Date ('May 8, 2019 16:00:00'), new Date ('May 8, 2019 20:00:00'), {location:"The Ritz",sendInvites:true}).getId();
    }elseif (guest == "Yes, I do plan to attend with a guest.") {var newEvent = CalendarApp.getDefaultCalendar().createEvent("Annual Service Awards", new Date ('May 8, 2019 16:00:00'), new Date ('May 8, 2019 20:00:00'), {location:"The Ritz",sendInvites:true}).getAdditionalGuests(1).getId();
    }elseif (guest == "No, I do not plan to attend.");//do nothing

Eric Koleda

unread,
Mar 20, 2019, 10:59:17 AM3/20/19
to google-apps-sc...@googlegroups.com
"else if" is two words in JavaScript (and therefore Apps Script):


- Eric

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/1512a6b3-d813-4665-9236-ee0cf1e10d80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages