Google apps script 想要从图纸中提取表单的选择列表吗

Google apps script 想要从图纸中提取表单的选择列表吗,google-apps-script,Google Apps Script,我正在尝试从Google表单中的一个范围生成的列表中预先填充Google表单中的下拉列表。我可以将列表拉入数组,但似乎无法在表单中创建选项 //Define sheet location (where vendor list range lives) and form location var se = SpreadsheetApp.openById("sheet_ID_that_works"); var vendorList = se.getSheetByName("vendorL

我正在尝试从Google表单中的一个范围生成的列表中预先填充Google表单中的下拉列表。我可以将列表拉入数组,但似乎无法在表单中创建选项

  //Define sheet location (where vendor list range lives) and form location
  var se = SpreadsheetApp.openById("sheet_ID_that_works");
  var vendorList = se.getSheetByName("vendorList");
  var vendorPullIn = sub.getRange("vendorListRange");
  var form = FormApp.openById('form_ID_that_works');
  var item = form.addListItem();
  item.setTitle('Select Vendor')
  var choiceList = vendorPullIn.getValues();
  item.setChoiceValues(choiceList);

选择需要在单个数组中。。。

.getValues返回一个二维数组

将值展平的一种方法

  var choiceList = [];
    var values = vendorPullIn.getValues();
    for ( var row in values )
      for ( var col in values[row] ) 
        if ( values[row][col] ) 
          choiceList.push( values[row][col] );