google apps script - Try Catch don't work properly -
i,m triyng create folder if doesn't exist , i'm using try/catch few days ago has stopped working. code. lot.
try { var folders = alumnospath.getfolders(); while (folders.hasnext()) { var folderp = folders.next(); var folderalumno = folderp.getname(); if (folderalumno == alumno2) { var folderid = folderp.getid(); var folder = driveapp.getfolderbyid(folderid);}}} catch (e){ var foldere = driveapp.getfolderbyid(alumnospathid).createfolder(alumno2).getid(); var folder = alumnospath.getfolderbyid(foldere);} catch (e){ var foldere = driveapp.getfolderbyid(alumnospathid).createfolder(alumno2).getid(); var folder = alumnospath.getfolderbyid(foldere);} folder.createfile(pdf);
the error (translate spanish): typeerror: can't call method "createfile" undefined.
the trouble script stops in catch(e) , no executes this.
unless alumno2
variable of string type, line:
if (folderalumno == alumno2) {
will never evaluate true, , therefore not file , folder id.
if alumno2
name of folder want, code should be:
if (folderalumno == "alumno2") {
put quotes.
Comments
Post a Comment