Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google apps script drive file: How to get user who last modified file?

To get the date a file was last updated you can call getLastUpdated()

How to I get the user who did this last update in google apps script code?

I have tried to run the code under listing revisions at Advanced Drive Service

var revisions = Drive.Revisions.list(fileId);

but I get

ReferenceError: "Drive" is not defined.
like image 467
Matthias Avatar asked Jan 10 '23 02:01

Matthias


2 Answers

https://developers.google.com/apps-script/guides/services/advanced

In Resouces > Advanced Google services, turn on Drive API...

enter image description here

In that same window > click Google Developer's Console >> enable both Drive API and Drive SDK... enter image description here

then...

Drive.Files.get('<FILEDID>').lastModifyingUser
like image 64
Bryan P Avatar answered May 19 '23 21:05

Bryan P


To make it clear:

First enable the drive API and SDK as described by Bryan P. Then you can use

var lastemailuser =  Drive.Files.get(<FILEDID>).lastModifyingUser.emailAddress;

var lastnameuser =  Drive.Files.get(<FILEDID>).lastModifyingUserName;
like image 40
Peter C Avatar answered May 19 '23 20:05

Peter C