Monday, October 21, 2013

Function for quick adding tasks or events to google calendar.

I have written a function so that you can quick add tasks as well as events to google calendar, using Google script.

"use strict";
 * @author Matthias Pall Gissurarson
 * @usage quickAddTaskOrEventFromString(quickadd);
 * @param quickadd A String describing the event to quickadd
function quickAddTaskOrEventFromString(quickadd) {
  //Add a task if the string includes " due ", otherwise add an event.
  if(quickadd.indexOf(" due ") !== -1){
    //Use the already implemented quickAdd to create an event.
    var event = CalendarApp.createEventFromDescription(quickadd);
    //This event gets automatically added to the users calendar, remove it.

    Create a new task, and have it have the same properties as the event.
    Tasks don't have dueTime as of now, so we add that to the note of the task.
    Also add the events location and description, these are often empty.
    var task = Tasks.newTask();


    //Add to the users default tasklist.
  } else {

    //Add the event as normal

function main() {
  var s = "Homework due tomorrow";
  var e = quickAddTaskOrEventFromString(s);
This function takes in a string, and if it contains " due ", it creates a task instead of an event on the default task list. Might this get implemented in the actual calendar?
I have posted a topic for this on the Google product forums. Let's see what happens.

No comments:

Post a Comment