We have hundreds of Google Sheets that are either modified by a human (through the UI) or by automation (that is run under a human ID). The modifications can be anything from changing cell values to adding a new sheet.
I am looking to programatically get the last time each file was modified by a human through the UI and not by the automation.
We cannot, and do not, want to add onEdit
code to each Sheet for various reasons.
I have checked both Drive.Revisions.list(fileID)
and Drive.Files.get(fileID)
but it does not show a distinction between how the edit was made -- either by the UI or by automation.
Is it possible to get the last modified date of a file but only for modifications made by a human using the web UI and not by automation?
Update:
I wanted to explain what I mean by "modifications made by a human using the web UI and not by automation".
There are two ways a Google Sheet could be edited.
- a human using the web UI = a human user opens his/her web browser, opens the Google Sheet document and starts making changes
- automation = a script/program programatically opens a Google Sheet document (for example,
SpreadSheetApp.openById(...)
) and then makes changes
The challenge is that if a Google Apps Script is executed under the context of a user (like me) then the normal activity logs of the file (like the last changed by user) will show that user even though they didn't make the change using the web UI, they made it using automation.
Update 2:
More details on our use-case:
- Our team uses Google Sheets for tracking details of our projects
- Each project has its own sheet
- As our team gets a new project, a new sheet is created from a template sheet
- The human users in our team open a sheet and make whatever updates they need
- We also have a Google Apps Script that, once a day, opens each sheet and does its own updates to the sheet
- The Google Apps Script is run on a daily trigger that I own
- I am also on the team so I also open sheets individually to make edits
So:
- Sheets are edited by the human members of our team, including me
- Or sheets are edited by a Google Apps Script that runs under my user
Now my need is that every day I need to collect the last time each sheet was edited by a human.
- I can't just check for last modified because it is possible the script made an edit and we do not want those
- I cannot exclude all edits made by me because I could have made changes to a sheet manually
I don't want to use onEdit
for each sheet because of the overhead. We don't want to end up with hundreds or thousands of Sheets each with their own script project tied to them. If there is ever a bug discovered in the code we would have to go and edit it for all the sheets -- not practical. And we already have a couple hundred sheets created that do not have any code in them so if we went the onEdit
route I would have to manually add them to every existing sheet.
modifications made by a human using the web UI and not by automation
. Can I ask you about the detail information of it? – TanaikeonEdit(e)
is a possible solution and ii) regardless of the number of sheets, you do not need (nor want) anonEdit
per sheet. – Tedinoz