Monday, January 11, 2010

New Apps Script Release

Even though we've been quiet for the last few months, rest assured that we've been hard at work making improvements to Apps Script. Today we're releasing some minor updates that address some issues that our users have encountered, and some that pave the way for future enhancements.

First off, we're making it easier to handle dates: up until now all scripts used the same timezone, the United States Pacific time zone. This made life a little difficult for users outside that zone (including the Apps Script team here in New York), who have had to deal with conversion back and forth to local time. From today, all new scripts will default to the creator's timezone as determined in the browser. Note that existing scripts will continue to work just as before, with their timezone still set to US Pacific.

We've also addressed an inconsistency in how we treat dates: in the past dates returned by Spreadsheets or Calendars were not true JavaScript dates, and lacked some functionality (such as getFullYear(), etc). This fix means that all dates are now fully JavaScript compliant, and support all Date() functionality.

Another issue with Spreadsheet integration relates to onEdit() event handling. The Spreadsheet's active sheet and active selection were not made available to the onEdit() functions, making it difficult to determine what was being edited. This is now fixed as the following code will demonstrate:

function onEdit(e) {
var doc = e.source;
doc.getActiveSelection().setBackground('#ff0000');
}

Lastly, we have fixed a recurring problem with CalendarEvent() - the functions for getting the start and end times of a calendar event, getStartTime() and getEndTime(), will now work properly.

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Suggestions:
    1) A place for us to post our scripts, and a way to organize them.
    2) In the API's, it would be nice if we had a wiki or some other place to discuss the documentation. Some of the names seem inconsistent (getActiveSelection vs. getRange), some that seem like they belong in multiple places don't, etc.)

    Nonetheless, I'm excited at the ability to add new features! This is cool!

    ReplyDelete
  3. this post implies that the onEdit event works for Google spreadsheets. I can't find any documentation that lists all available events that can be used to trigger code. Can you point me to a list of event triggers that are available?

    ReplyDelete
  4. I can not understand - e.source

    ReplyDelete