0

So my company recently moved from a shared drive to a team drive and we have a google sheet script that uses the method

Session.getEffectiveUser().getEmail();

but I get this error when running the script

TypeError: Cannot call method "getEmail" of null.

It worked when the file was in or is in My drive but it doesn't work if it is in the Team Drive. I've also called it in the Logger in the script editor while the script is in the Team Drive and it returns the correct value. I've also tried this method.

Session.getActiveUser().getEmail();

Jean Park
  • 1
  • 1
  • Have you reviewed documentation on the many differences between Google Drive and Team Drive? They have different permission sets. Also, do not show error messages or code in images. – tehhowch Jul 31 '18 at 18:52
  • https://developers.google.com/apps-script/guides/collaborating#collaborating_with_team_drives – tehhowch Jul 31 '18 at 18:59
  • I currently have Edit access to the file and Full access to the folder but I don't see a higher access to the file. Is it a permission thing on the file? or a user access I don't have the rights to? – Jean Park Jul 31 '18 at 21:40

1 Answers1

0

I suggest you to create a custom trigger e.g. MyonEdit, that uses onEdit. (Edit → View Current Project Triggers). getUser().getEmail return values now.

My issue was sheets saved to My Drive returned getUser() correctly, but came back null when the sheet was saved to a Team Drive.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Jonnie
  • 1