我有以下情况
我目前正在使用正常运行的appscript更新表单,但是我遇到了这个问题,表单有一个问题(从国家的下拉列表中选择一个国家),每个选项都映射了每个部分,(例如,如果我选择country作为荷兰,同时填写表格,它将带我到下一部分以在指定的部分中选择荷兰的城镇),所以现在发生的事情是,只要在工作表中添加了新国家(通过以下脚本在表格中对其进行更新),它就可以正常工作很好,但是它会重置为每个国家/地区设置的剖面图,因此我们必须再次重做基于剖面的答案!想了解是否有任何方法可以避免重置基于节的选项集。]
代码
var ssID = "sheet ID"; //Global Variable sheet ID
// This is start of function1 to update form Monthly
function formUpdateCC() {
// call your form and connect to the drop-down item
var form = FormApp.openById("form ID");
var country = form.getItemById("ItemID").asListItem();
// identify the sheet where the data resides needed to populate the drop-down - Countrylist
var countrysheet = SpreadsheetApp.openById(ssID).getSheetByName("Country");
// grab the values in the first column of the country tab in sheet - use 2 to skip header row
var countrylist = countrysheet.getRange(2, 1, countrysheet.getMaxRows() - 1).getValues();
var data = [];
// convert the array ignoring empty cells
for (var i = 0; i < countrylist.length; i++)
if (countrylist[i][0] != "")
data[i] = countrylist[i][0];
country.setChoiceValues(data);
}
我有以下情况,我目前正在使用正常运行的appscript更新表单,但是我遇到了这个问题,我的表单有一个选择国家的问题(从...的下拉列表中)
var form = FormApp.openById("Form Id");
var countryChoices = form.getItemById(195034774).asListItem().getChoices();
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);