When I run the below code manually it works fine, but when running on a trigger it fails. I had a look for this FULL
in the Google documentation, and the only context I can see it in is to do with permissions, but I think this already has full permission.
Full error code:
TypeError: Cannot find function getMessages in object FULL.
at getCalendarInvites(Calendar:44)
at removePastInvites(Calendar:11)
Relevant parts of my code
function removePastInvites(threads) {
var labelName = "Past Events";
var days = 5;
var count = 0;
var archivedEmails = []
var email = "foo@bar.com"
if (threads == null) {
var threads = GmailApp.getInboxThreads(); // did this so that I can either call the method directly or pass
// threads in from a separate method call
}
var calendarInvites = getCalendarInvites(threads); // line 11
...
...
...
function getCalendarInvites(threads) {
var messages, attachments;
var inviteEmails = [];
for (thread in threads) {
messages = threads[thread].getMessages() // line 44
What I've tried/workaround
I could do something like this
function removePastInvitesNoArgs() {
var threads = ...
removePastInvites(threads)
}
function removePastInvites(threads) {
// original code
}
But I still don't really understand why my original script doesn't work.
Update: I have taken the (for..in)
feedback on board, and this had some side-effects, but was not the main cause of the problem.