似乎onEdit(e)不会触发在Google驱动器中创建新文件夹-仅在明确运行它时才起作用。有任何想法吗?谢谢
function onEdit(e) {
var requestRow = e.range.getRow();
var folderName = SpreadsheetApp.getActiveSheet().getRange(requestRow,6).getValue();
var newFolder = DriveApp.getFolderById('1LOfkVGrV-juzUiwbU8owHj74T9wMAz').createFolder(folderName);
}
答案 0 :(得分:0)
尝试一下:
function func1(e) {
DriveApp.getFolderById('1LOfkVGrV-juzUiwbU8owHj74T9wMAz').createFolder(SpreadsheetApp.getActiveSheet().getRange(e.range.rowStart,6).getValue());
}
function isTrigger(funcName){
var r=false;
if(funcName){
var allTriggers=ScriptApp.getProjectTriggers();
for(var i=0;i<allTriggers.length;i++){
if(funcName==allTriggers[i].getHandlerFunction()){
r=true;
break;
}
}
}
return r;
}
运行一次以创建触发器。
function createOnEditTrigger() {
if(!isTrigger('func1')){
ScriptApp.newTrigger('func1').forSpreadsheet(SpreadsheetApp.getActive().getId()).onEdit().create();
}
}