我在Google Apps中有以下脚本:
function createSpreadsheet(environment, timestamp) {
Logger.log(environment);
var folders = DriveApp.getFoldersByName(environment);
while (folders.hasNext()) {
var folder = folders.next();
}
var testName = timestamp + ".test_" + environment;
Logger.log(testName);
var file = {
"title": testName,
"mimeType": "application/vnd.google-apps.spreadsheet",
"parents": [
{
"id": folder.getId()
}
]
};
Drive.Files.insert(file);
var allFiles = folder.getFilesByName(testName);
var files = {};
while (allFiles.hasNext()) {
var file = allFiles.next();
return file.getId();
}
}
从Ruby代码我正在执行以下调用
request = Google::Apis::ScriptV1::ExecutionRequest.new
request.function = 'createSpreadsheet'
request.parameters = [environment.to_s ,timestamp.to_s ]
但它没有用,我在执行脚本时遇到错误:
Script error message: Cannot call method "getId" of undefined.
我做错了什么?这些参数是一个简单的字符串
非常感谢
答案 0 :(得分:0)
我的错是忘记在剧本中发布我的最后一次更改