I have a Sheet where I need to get the id of a file located in my Google-drive. I have written the folowing script:
function get_id_pdf() {
var nom='INV432-altaïr-Famille XXX-XXX Marie-03-2016.pdf';
var files = DriveApp.getFilesByName("'"+nom+"'");
while (files.hasNext()) {
var file = files.next();
var name = file.getName();
var type = file.getMimeType();
var url = file.getUrl();
var id = file.getId();
// Logger.log(file.getId());
return file.getId();
}
}
If I execute it in the Script editor (with the run
button), it is working well (I get the id the the Log).
But If I call the script from a cell (in the cell: =get_id_pdf()
) of my Google-Sheet, I get the error:
"You do not have permission to call getFilesByName" (see image)
I have of course all the authorization to access to this file (it is in my own drive, and the file havs been created by me).
Does somebody have an idea ?
Regards.