Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Wednesday, February 1, 2017

Google Apps Script: Get Script Id, Object and Parent Folder

.
function myFunction() {
//get script id and parent folder
  var scriptId=ScriptApp.getScriptId();
  var script=DriveApp.getFileById(scriptId);
 var parentFolder = script.getParents();
 while (parentFolder.hasNext()) {
   var folder = parentFolder.next();
   Logger.log(folder.getName());
 }  

  //test
  var doc = DocumentApp.create('Document Name'),
  docFile = DriveApp.getFileById( doc.getId() );
  DriveApp.getFolderById(folder.getId()).addFile( docFile );
  DriveApp.getRootFolder().removeFile(docFile);
 }
 
 
.

No comments:

Post a Comment