将对话框响应复制到单元格

Copy Dialog Box Response to a Cell

所以我是 Google 脚本的新手,不确定我到底做错了什么。我正在尝试将结果从对话框复制到 google 工作表中的单元格。但是,我正在尝试的当前方法不起作用,我收到的回复是 "Cannot Find Function to CopyTo in Object (Response)"

function Cancel() {
  var ui = SpreadsheetApp.getUi();

  var result = ui.prompt(
      'What day did you cancel?',
      'Please enter the date as mm/dd/yyy',
      ui.ButtonSet.OK_CANCEL);

  // Process the user's response.
  var button = result.getSelectedButton();
  var text = result.getResponseText();
  var sheet = SpreadsheetApp.getActiveSheet(),
    row = sheet.getLastRow();

  if (button == ui.Button.OK) {
    // User clicked "OK".
    sheet.insertRowAfter(row);
      text.copyTo(sheet.getRange(row + 1, 1));
    ui.alert('The Date has Been Recorded');
  } else if (button == ui.Button.CANCEL) {
    // User clicked "Cancel".
    ui.alert('I did not get your name.');
  } else if (button == ui.Button.CLOSE) {
    // User clicked X in the title bar.
    ui.alert('You closed the dialog.');
  }
}

谁能看看我的代码并就如何将响应复制到单元格提出建议。任何帮助将不胜感激。

怎么样:

而不是:text.copyTo(sheet.getRange(row + 1, 1));

尝试:sheet.getRange(row + 1, 1).setValue(text);