Posts

Showing posts with the label google apps script

GmailThread ID is evil

Seems like GmailThread.getId() isn't always persistent. What good is a primary key which can occasionally change its value ? I've now verified that this behavior is so unexpected that it is documented as well. The recommended workaround is to not use the Thread ID, but use the ID of each message instead. However, this gets messy as if you want a persistent reference to a thread, you need to do the following dance: var id = thread.getMessages()[0].getId(); // serialize id, and read it back later var thread2 = GmailApp.getMessageById(id).getThread(); Which kind of defeats the purpose of not needing to do slow fetching of all messages of each thread to draw conclusions about the thread itself  when processing a search result. Yes, I'm trying to simulate Gmail filters by hand and need to watch out for quotas. I think I'm going for a hack based on getFirstMessageSubject() and/or getPermaLink(). And before you ask: no, there is no such thing as getThreadByPermaLink()...

Please wait a bit for Apps Script, then wait a bit more

An unescaped stray plus in a regexp caused all scripts in my project to fail to trigger, not just the ones within the error's reachability tree. I was presented with the following notification when trying to start one manually: We're sorry, a server error occurred. Please wait a bit and try again. I usually discover such complex interactions earlier, but in this case I was tired and I wasn't in a hurry, so I blindly chose to wait until the "server error" gets resolved. I've only STFW after getting back to see if the issue has resolved by itself. StackOverflow: Google Apps Script: We're sorry, a server error occurred. Please wait a bit and try again Specifically, the code contained: string.replace(/+.*$/, '') instead of string.replace(/\+.*$/, '') The editor doesn't let you even save the file if it contains any other kind of syntax error, but this behavior seems to be some kind of a bug.

Google Apps Script external version control almost here

Many have desired to collaborate in the development of Google Apps Scripts. Two outstanding issues had been open for some time in this area: Issue 1959: Collaborative editing of scripts Issue 217: Make Google Code the back-end version control for collaborative scripting A feature offered from June enables API access of script source code. This potentially enables connection to an external repository, like Google Code or GitHub. See the linked screencast and talk or the API below. YouTube: Apps Script Crash Course: Import/Export Apps Script Code Google Developers: Importing and Exporting Projects After breaking this barrier, I can now start gathering some of my more useful scripts to share via bkil-open, though I'll probably simply copy&paste for now.