I am trying to get the ID of the doc that I am working on. Currently I am using
var files = DriveApp.getFileById('whatever the doc Id is')
and this works fine. However, I want to be able to get any document Id that this application may be running on. I don't want the user to go into the code and switch the ID depending on what document they are on. If anyone has any ideas I would love to hear them,
Thanks
You get the document ID from the URL of the file. For example, if the URL of a file is https://docs.google.com/document/d/1LQ_zgy0QDy/edit , the document ID is 1LQ_zgy0QDy .
Run by clicking on the right-pointing triangle in the button bar. 'Authorization required ' pop up will appear; grant authorization. A listing of the files in the specified folder, along with URLs for those files, will then appear in your My Drive as a Google Sheet named listing of folder {your-folder}
A basic approach to logging in Apps Script is to use the built-in execution log. To view these logs, at the top of the editor, click Execution log. When you run a function or use the debugger, the logs stream in real time. You can use either the Logger or console logging services in the built-in execution log.
Geez I should really have more faith in my guess and check abilities.
var files = DriveApp.getFileById(DocumentApp.getActiveDocument().getId());
files.setDescription(des);
This works
The id for a file/folder is also in its url. Opening a file you want the id for, your url bar says: https://docs.google.com/document/d/exampleid1234qwer5678tyui/edit
The id for that doc will be: exampleid1234qwer5678tyui
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With