I am setting up a trivia game through google sheets/forms. I have a google form that makes a team enter in their team name and submit. This then goes back to a google sheet with time stamps. I want these responses to then be pulled into a drop down menu for my next 18 questions of trivia through google forms. Using the form ranger in google forms it will only update every hour or manually. I am trying to write a code that will update itself every minute or so.
Write this code in Google Apps Script
function changeForm() {
var form = FormApp.openById("enter your form id here");
var items = form.getItems();
//get form id from inspect element at <input id=???>
var question1 = form.getItemById('question id').asListItem();
var ss = SpreadsheetApp.openById("your sheet id");
var sheet = ss.getSheetByName("Form Responses 1");
var row = sheet.getLastRow();
var answer = sheet.getRange(1, 2, row).getValues(); //range of answer
question1.setTitle("title")
.setRequired(true) //true or false
.setChoiceValues(answer);
}
Then, save your project and go to Your project in Google Apps Script .
Click at your project.
Click three dots button, and choose "Triggers".
Click "Add Trigger".
Set your function name.
Set "Select event source" is "Time-driven"
Set your time to trigger
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.