'I need to get the date a file was created from a google apps script but im being told getDateCreated and getlastUpdated arent functions?
As the title suggest I have an Apps script where I need the Date created of the google doc but when i use the following code ''' var file = DriveApp.getFilesByName("filename") var final = file.getDateCreated()''' I get told that getDateCreated isnt a function and the same issue happens with getlastUpdated can anyone point out what im missing. Many thanks.
Solution 1:[1]
DriveApp.getFilesByName("filename") returns a FileIterator not a File. You need to iterate through the files, even if there is only one file with that name.
function test() {
try {
var files = DriveApp.getFilesByName("filename");
while( files.hasNext() ) {
var file = files.next();
console.log(file.getDateCreated());
}
}
catch(err) {
console.log(err);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Irvin Jay G. |
