I want each user (at the company I work at) to log Gmail-data into (a 3rd party system) Harvest.
I distributed an Apps Script by having a html-webbapp where each individual user starts triggers (that runs a singel function) by pressing a button.
My problem is that everything works correctly only when it runs manually. When the function is triggered, the Gmail-data is logged to my user (and not the user that runs it). I have logged on to a user (experiencing this issue) and the triggers are set up correctly. The function runs correctly when triggered manually.
Psudo-code:
var user = Session.getEffectiveUser().getEmail();
var gmailData = GmailApp.getInboxThreads(0,1)[0];
UrlFetchApp.fetch(
"https://api.com",
{
"headers": {'Authorization':"hash of admin (my) user/pw"},
"method": "post",
"payload": "add data " + gmailData + " to user " + user
}
);
Webapp ran an old version with one result, and manual was current code. Updating to new version solved my issue.