This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Google Calendar Integration


  1. jeannewey
    Member

    Has anyone integrated Machform with the Google Calendar API? We want to use MF for a transportation booking system and we want the booking date and details to be automatically sent to our Google Calendar. I found code for Google sites and forms (below). I can probably figure it out within a few days, but don't want to repeat work if someone has already done it.

    This would be a FANTASTIC enhancement and the Google Calendar API was simplified this year, too.

    https://sites.google.com/site/appsscripttutorial/calendar-services/create-calendar-events-by-submitting-form

    //Create the GUI form

    function doGet() {
    var app = UiApp.createApplication().setTitle('Form and Calendar Events');

    //Create a penel which holds all the form elelemnts
    var panel = app.createVerticalPanel().setId('panel');

    //Create the form elelemnts
    var eventDateLabel = app.createLabel('Event Date:');
    var evenDate = app.createDateBox().setId('eventDate');
    var eventTitleLabel = app.createLabel('Event title:');
    var eventTitle = app.createTextBox().setName('eventTitle').setId('eventTitle');
    var eventDeatilLabel = app.createLabel('Event Details:');
    var eventDetail = app.createTextArea()
    .setSize('200', '100').setId('eventDetail').setName('eventDetail');
    var btn = app.createButton('createEvents');

    //Create handler which eill execute 'createEvents(e)' on clicking the button
    var handler = app.createServerClickHandler('createEvents');
    handler.addCallbackElement(panel);
    //Add this handler to the button
    btn.addClickHandler(handler);

    //Add all the elemnts to the panel
    panel.add(eventDateLabel)
    .add(evenDate)
    .add(eventTitleLabel)
    .add(eventTitle)
    .add(eventDeatilLabel)
    .add(eventDetail)
    .add(btn);
    //Add this panel to the application
    app.add(panel);
    //return the application
    return app;
    }

    function createEvents(e){

    //Get the active application
    var app = UiApp.getActiveApplication();

    try{
    //get the entries;
    var eventDate = e.parameter.eventDate;
    var eventTitle = e.parameter.eventTitle;
    var eventDetails = e.parameter.eventDetail;

    //Get the calendar
    var cal = CalendarApp.getCalendarsByName('Calendar-Name')[0];//Change the calendar name
    var eventStartTime = eventDate;
    //End time is calculated by adding an hour in the event start time
    var eventEndTime = new Date(eventDate.valueOf()+60*60*1000);
    //Create the events
    cal.createEvent(eventTitle, eventStartTime,eventEndTime ,{description:eventDetails});

    //Log the entries in a spreadsheet
    var ss = SpreadsheetApp.openById('Spreadsheet-Key');//Change the spreadhseet key to yours
    var sheet = ss.getSheets()[0];
    sheet.getRange(sheet.getLastRow()+1, 1, 1, 5).setValues([[new Date(), eventDate,eventTitle, eventDetails, 'Event created']]);

    //Show the confirmation message
    app.add(app.createLabel('Event created Successfully'));
    //make the form panel invisible
    app.getElementById('panel').setVisible(false);
    return app;
    }

    //If an error occurs, show it on the panel
    catch(e){
    app.add(app.createLabel('Error occured: '+e));
    return app;
    }
    }

    Posted 10 years ago #
  2. yuniar

    We don't have anything for Google calendar yet, for the current version. However, the next version (v4) would allow you to integrate your form with Google calendar API (we'll post some previews and details soon within our blog).


    MachForm Founder

    Posted 10 years ago #
  3. he4gaveme
    Member

    Would it also then be possible to integrate with Google Contacts?

    Posted 10 years ago #
  4. cscrofani
    Member

    Will the planned integration be able to restrict available dates/times based on timeslots that are already populated in the calendar?

    For instance, if there is a form for people to choose which time they want to take a tour, and there's only two spots available on a certain time/date, will machform be able to read the calendar and only allow people to choose the available dates/times?

    Posted 10 years ago #
  5. atteam
    Member

    Occasionally I visit this forum to see if there's any blog update, or if Machform is still actively developed. Glad hearing about version 4 preview coming soon.
    I forgot to renew my license last year (oops, no reminder was sent either..)

    Posted 10 years ago #
  6. johanstulens
    Member

    Any news on integration with Google Calendar yet ?

    I allso would like to use machform to add to a Google Calendar.

    Posted 9 years ago #
  7. yuniar

    Unfortunately, my post from 7 month above is no longer valid. Google now enforced all API integration to use OAuth2 for the authentication, hence it won't work with the new webhook functionality within v4.


    MachForm Founder

    Posted 9 years ago #

RSS feed for this topic

Reply