Matthias
Matthias

Reputation: 1162

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.

Upvotes: 4

Views: 6513

Answers (2)

Peter C
Peter C

Reputation: 21

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;

Upvotes: 1

Bryan P
Bryan P

Reputation: 5051

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

Upvotes: 8

Related Questions