Google apps script Google AppScript-使用AppScript更新Google表单
我有下面的场景 我目前使用appscript更新我的表单,该脚本工作正常,但我有这个问题,我的表单有选择国家的问题(从国家下拉列表中),每个选项都映射了每个部分,(假设我在填写表格时选择国家作为荷兰,我将进入下一部分,在指定部分选择荷兰的城镇),所以现在的情况是,无论何时在工作表中添加了新的国家/地区,它都会通过下面的脚本在表单中进行更新,并且工作正常,但它会重置为每个国家/地区设置的分区地图,因此我们必须再次重做基于分区的答案!想了解是否有任何方法可以避免重置已设置的基于分区的选项 代码Google apps script Google AppScript-使用AppScript更新Google表单,google-apps-script,google-sheets,google-forms,Google Apps Script,Google Sheets,Google Forms,我有下面的场景 我目前使用appscript更新我的表单,该脚本工作正常,但我有这个问题,我的表单有选择国家的问题(从国家下拉列表中),每个选项都映射了每个部分,(假设我在填写表格时选择国家作为荷兰,我将进入下一部分,在指定部分选择荷兰的城镇),所以现在的情况是,无论何时在工作表中添加了新的国家/地区,它都会通过下面的脚本在表单中进行更新,并且工作正常,但它会重置为每个国家/地区设置的分区地图,因此我们必须再次重做基于分区的答案!想了解是否有任何方法可以避免重置已设置的基于分区的选项 代码 v
var ssID=“sheet ID”//全局变量sheet ID
//这是每月更新表单的功能1的开始
函数formUpdateCC(){
//调用表单并连接到下拉项
var form=FormApp.openById(“form ID”);
var country=form.getItemById(“ItemID”).asListItem();
//确定填充下拉列表所需的数据所在的工作表-Countrylist
var countrysheet=SpreadsheetApp.openById(ssID).getSheetByName(“国家”);
//抓取工作表中“国家”选项卡第一列中的值-使用2跳过标题行
var countrylist=countrysheet.getRange(2,1,countrysheet.getMaxRows()-1.getValues();
var数据=[];
//转换数组时忽略空单元格
对于(变量i=0;i
您可以使用with而不是setChoiceValues向选项添加导航。为要导航到该国家/地区的节创建一个带有节ID的新列(在本例中为B列)。然后使用下面的代码更新表单
var form = FormApp.openById("Form Id");
var country = form.getItemById("List Id").asListItem();
// identify the sheet where the data resides needed to populate the drop-down - Countrylist
var countrysheet = SpreadsheetApp.openById(ssID).getSheetByName("Country");
// create a new column next to the country name for its target pagebreak ID from the form
// grab the values in the first & second columns of the country tab in sheet - use 2 to skip header row
var countrylist = countrysheet.getRange(2, 1, countrysheet.getMaxRows() - 1).getValues();
var targetlist = countrysheet.getRange(2, 2, countrysheet.getMaxRows() - 1).getValues();
var data = [];
// convert the array ignoring empty cells
var s = 0;
for (var i = 0; i < countrylist.length; i++)
if (countrylist[i][0] != "") {
// use createChoice(value, navigationItem) to add the section navigation
data[s] = country.createChoice(countrylist[i][0], form.getItemById(targetlist[i][0]).asPageBreakItem());
s++;
}
country.setChoices(data);
var form=FormApp.openById(“表单Id”);
var country=form.getItemById(“列表Id”).asListItem();
//确定填充下拉列表所需的数据所在的工作表-Countrylist
var countrysheet=SpreadsheetApp.openById(ssID).getSheetByName(“国家”);
//从表单中为其目标分页符ID在国家名称旁边创建一个新列
//获取工作表中“国家/地区”选项卡第一列和第二列中的值-使用2跳过标题行
var countrylist=countrysheet.getRange(2,1,countrysheet.getMaxRows()-1.getValues();
var targetlist=countrysheet.getRange(2,2,countrysheet.getMaxRows()-1.getValues();
var数据=[];
//转换数组时忽略空单元格
var s=0;
对于(变量i=0;i
您可以使用with而不是setChoiceValues向选项添加导航。为要导航到该国家/地区的节创建一个带有节ID的新列(在本例中为B列)。然后使用下面的代码更新表单
var form = FormApp.openById("Form Id");
var country = form.getItemById("List Id").asListItem();
// identify the sheet where the data resides needed to populate the drop-down - Countrylist
var countrysheet = SpreadsheetApp.openById(ssID).getSheetByName("Country");
// create a new column next to the country name for its target pagebreak ID from the form
// grab the values in the first & second columns of the country tab in sheet - use 2 to skip header row
var countrylist = countrysheet.getRange(2, 1, countrysheet.getMaxRows() - 1).getValues();
var targetlist = countrysheet.getRange(2, 2, countrysheet.getMaxRows() - 1).getValues();
var data = [];
// convert the array ignoring empty cells
var s = 0;
for (var i = 0; i < countrylist.length; i++)
if (countrylist[i][0] != "") {
// use createChoice(value, navigationItem) to add the section navigation
data[s] = country.createChoice(countrylist[i][0], form.getItemById(targetlist[i][0]).asPageBreakItem());
s++;
}
country.setChoices(data);
var form=FormApp.openById(“表单Id”);
var country=form.getItemById(“列表Id”).asListItem();
//确定填充下拉列表所需的数据所在的工作表-Countrylist
var countrysheet=SpreadsheetApp.openById(ssID).getSheetByName(“国家”);
//从表单中为其目标分页符ID在国家名称旁边创建一个新列
//获取工作表中“国家/地区”选项卡第一列和第二列中的值-使用2跳过标题行
var countrylist=countrysheet.getRange(2,1,countrysheet.getMaxRows()-1.getValues();
var targetlist=countrysheet.getRange(2,2,countrysheet.getMaxRows()-1.getValues();
var数据=[];
//转换数组时忽略空单元格
var s=0;
对于(变量i=0;i