google apps script - Using the makeCopy with DriveApp -
my code use work since couple of weeks im having trouble.
first defined moovefile function:
function moovefile(file,folder,source,copynamefile){ var newfile = file.makecopy(copynamefile, folder); source.removefile(file); logger.log(source.getfiles().length); return newfile.geturl(); }
then im calling function later in script:
if (statutfile=="validé") { var fichiersj=foldersource.getfilesbyname(libelefile); while (fichiers.hasnext()) { var fichiersj = fichiers.next();} var urlfichierval = moovefilde(fichiersj,foldervalid,foldersource,nomfichier); sheetform.getrange(i+1,23).setvalue("deplacé"); if (typefichier == "devis") { sheetform.getrange(i+1,34).setvalue(urlfichierval);} if (etatlien !="lien modifiée") { var urlfichiervalide = urlfichierval; var hyp = '"'+urlfichiervalide+'"'; var arghyp = ";"; var sephyp = '"'; var hrefhyp = "=hyperlink("+hyp+arghyp+sephyp+"accèder au "+typefichier+" validé"+'")'; sheetform.getrange(i+1,18).setvalue("lien modifiée"); sheetform.getrange(i+1,6).setvalue(hrefhyp); } }
the error got is:
typeerror: impossible call "makecopy" method undefined.
it seems me problem come the:
while (fichiers.hasnext()) { var fichiersj = fichiers.next();}
however don't know how became undefined. uses work well!
looks have } in code, on line:
var fichiersj = fichiers.next();}
this ending while loop after line, instead of executing rest of code.
once while loop finishes, "fichiersj" undefined, since defined within loop.
Comments
Post a Comment