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

℡╲_俬逩灬. 提交于 2021-02-04 04:56:46

问题


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.

回答1:


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



回答2:


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;


来源:https://stackoverflow.com/questions/28017673/google-apps-script-drive-file-how-to-get-user-who-last-modified-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!