It’s been a while since I’ve posted anything, so bear with me please! I’ve successfully loaded dropdown options from google sheets into google forms. I’m using a trigger to update the form anytime the data in the sheet is changed (i.e. a new name is added to the list). The problem is that the “Go to section based on answer” choice is erased every time the update occurs. How can I implement this into my code? I’ve initialized the variable “goTo” to represent the section I’ll assign to each choice in the dropdown (this will be achieved with a select statement).
<code>function getDataFromSheets () {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const GOOGLE_SHEET_NAME = 'Trial Name Load';
const[header,...data]=ss.getSheetByName(GOOGLE_SHEET_NAME).getDataRange()
.getDisplayValues();
const choices = {};
header.forEach(function(title, index) {
choices[title] = data.map(row => row[index]).filter((e) => e);
});
return choices
}
function populateGoogleForm() {
var goTo = ""
const GOOGLE_FORM_ID = '1FUB...........................MbQ8';
const googleForm = FormApp.openById(GOOGLE_FORM_ID)
const items = googleForm.getItems();
const choices = getDataFromSheets();
items.forEach(function(item){
const itemTitle = item.getTitle();
if (itemTitle in choices) {
item.asListItem().setChoiceValues(choices[itemTitle]);
}
});
}
</code>
<code>function getDataFromSheets () {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const GOOGLE_SHEET_NAME = 'Trial Name Load';
const[header,...data]=ss.getSheetByName(GOOGLE_SHEET_NAME).getDataRange()
.getDisplayValues();
const choices = {};
header.forEach(function(title, index) {
choices[title] = data.map(row => row[index]).filter((e) => e);
});
return choices
}
function populateGoogleForm() {
var goTo = ""
const GOOGLE_FORM_ID = '1FUB...........................MbQ8';
const googleForm = FormApp.openById(GOOGLE_FORM_ID)
const items = googleForm.getItems();
const choices = getDataFromSheets();
items.forEach(function(item){
const itemTitle = item.getTitle();
if (itemTitle in choices) {
item.asListItem().setChoiceValues(choices[itemTitle]);
}
});
}
</code>
function getDataFromSheets () {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const GOOGLE_SHEET_NAME = 'Trial Name Load';
const[header,...data]=ss.getSheetByName(GOOGLE_SHEET_NAME).getDataRange()
.getDisplayValues();
const choices = {};
header.forEach(function(title, index) {
choices[title] = data.map(row => row[index]).filter((e) => e);
});
return choices
}
function populateGoogleForm() {
var goTo = ""
const GOOGLE_FORM_ID = '1FUB...........................MbQ8';
const googleForm = FormApp.openById(GOOGLE_FORM_ID)
const items = googleForm.getItems();
const choices = getDataFromSheets();
items.forEach(function(item){
const itemTitle = item.getTitle();
if (itemTitle in choices) {
item.asListItem().setChoiceValues(choices[itemTitle]);
}
});
}