Google Calendar integration with custom calendar object?

  • 2
  • Question
  • Updated 5 months ago
  • In Progress
We are a school with multiple teachers. The teachers are not assigned specific salesforce licenses. We have created a custom object for calendaring the teachers classes and wonder if we can show these custom calendars on google, teacher by teacher. Our teachers do have their own google accounts. 
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb

Posted 5 months ago

  • 2
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Anna,

I think that what you want to do is possible, but I am not sure that the 'experience' is what you want.  Since your connection to Google Calendar is only 'through' Skuid, you would have to open each teacher's calendar and 'push' the classes to the Google Calendar for each teacher.  This could be done declaratively on a class by class basis or using a snippet to copy all classes to their Google Calendar.  You would also need to have a way to 'link' or 'find' these 'added' calendar items to be able to update them when they change or remove and re-add them.

I think the better answer is to create a trigger that syncs the class 'events' from Salesforce to the teacher's Google Calendar.  You might also be also be able to do something using one of the lightweight integration platforms like If This Then That or Zapier.

Thanks,

Bill
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
Is the "event" that you are referring to the event under the salesforce activities object, or could it be a custom event object? Also, will these instructions work? https://docs.skuid.com/latest/en/data/google/google-calendar.html#configuration or is this only for the native Salesforce event/activities object?
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Anna,

What I was suggesting could be done with any object in Salesforce.  You would view your Salesforce object and then have a feature that would 'push' those to Google Calendar.  You would be copying the items from your custom object into Google Calendar items.  When you want to 'refresh' you could delete the Google Calendar items and then re-add them from your custom object.  This would all be user initiated from your Skuid page.

Thanks,

Bill
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
Thanks Bill. Do you have an example of a snippet that we could use to push the data? We used to have Zapier, but now don't. I could look into that. 
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
FYI:
I did these steps: 
1. Set up google as a data source in skuid: https://docs.skuid.com/latest/en/data/google/
2. Created a skuid page with a calendar component and two models--one for the google calendar and one for the events like it says here: https://docs.skuid.com/latest/en/data/google/google-calendar.html
3. Then I created tables on the skuid page with our custom event objects and created a mass edit code to select the rows and create google calendar events for them for one teacher's classes:

params = arguments[0],
$ = skuid.$,
    action = arguments[0].action,
    list = arguments[0].list;
    model = arguments[0].model,
    selectedItems = list.getSelectedItems();

var AnnaCalModelId=skuid.model.getModel("MMA_Program_Session_Group_Anna").data[0].Id;
console.log(AnnaCalModelId + " AnnaCalModelId ");

if(AnnaCalModelId) {
    
    var GoogleModel=skuid.model.getModel("Anna_GCalendar_Events");
    
    $.each( selectedItems,
        function( i, item )
        {
            var row = item.row;
            console.log(row.Id);
            
            //get the START date/time from the MMA_Program_Session_Group_Anna
            var start_date_and_time=row.Start_Date_and_Time__c;
            console.log(' start_date_and_time ' + start_date_and_time);
            //var sf_start_date_time=row.start_date_and_time;
            var sf_start_date_time=row.Start_Date_and_Time__c;
    
            //get the END class date and time from the MMA_Program_Session_Group_Anna
        var end_date_and_time=row.End_Date_and_Time__c;
        console.log(' end_date_and_time ' + end_date_and_time);
        //var sf_end_date_time=row.End_Date_and_Time__c;
            var sf_end_date_time=row.End_Date_and_Time__c;
    
            //GET JAVASCRIPT VALUES OF DATE/TIME FIELDS
            //get javascript version Start Date/Time 
            var js_start_date_time=skuid.time.parseSFDateTime(start_date_and_time);
            //get javascript version End Date/Time
            var js_end_date_time=skuid.time.parseSFDateTime(end_date_and_time);  
            
            var newRow=GoogleModel.createRow({
                additionalConditions: [
                    {field:'summary', value:row.MMA_Program__r.Name},
                    {field:'startDateTime', value:js_start_date_time},
                    {field:'endDateTime', value:js_end_date_time}
                     
                    ], doAppend: true
            });
        });
        GoogleModel.save({callback: function(result){
        if (result.totalsuccess) {
            alert('Event was created in google');
        } else {
            console.log(result.insertResults);
            console.log(result.updateResults);
            console.log(result.deleteResults);      
        }
    }});
}
else{
    alert('Select a row in the table to create a google calendar event for.');
}
 4. Now I need to figure out how to sync the google events with our custom salesforce event objects so that changes may be tracked. How do I do this when there is no actual model for the google calendar or its events outside of skuid? Here are some ideas:
  • add to a field to our internal events that will hold the google event id for each corresponding event entry in google. When the code is used to create the google events from our events, have it fill in the google id on our skuid event. Use that correlation to create a sync somehow. Maybe a change on the skuid event creates an alert -- "this event needs to be changed in google" -- and then we create some system to find the event and update it?
  • Is there a way to create a salesforce object from these skuid google calendar models so that we can use workflow and process builder on it when there are changes?
Thanks for the help!
(Edited)
Photo of Anna Orias

Anna Orias

  • 1,468 Points 1k badge 2x thumb
Is there something here that we could use? https://developers.google.com/calendar/v3/sync