Home >Web Front-end >JS Tutorial >Automation for Google Forms
PT-BR
I was asked to create a smart form, where it would update a specific item according to what the user entered. As a kind of ID.
Through AppsScript, I created the following code below to accomplish this:
function updateForms() { const id = "Enter your SpreadSheet ID here!"; const sheetName = "Enter the Sheet's name of items want to be auto uploads!"; const ss = SpreadsheetApp.openById(id); const sheet = ss.getSheetByName(sheetName); const range = sheet.getDataRange().getValues(); // i recommend you do a sheet only to set data'll be upload const choiceValues = [...new Set(range.map(row => row[0]).filter(value => value))]; const form = FormApp.openById("Enter your Forms ID here!"); const items = form.getItems(); for (var i in items) { if (items[i].getTitle() == "Set here the question name of Forms!") { items[i].asListItem().setChoiceValues(choiceValues); return; } } Logger.log("Nothing found..."); }
The code was to update the data that would feed a weekly report.
Find more information in the repository.
EN-US
I was asked to create a smart form that would update a specific item based on what the user entered. Like a sort of ID.
Using AppsScript, I created the following code to do this:
function updateForms() { const id = "Enter your SpreadSheet ID here!"; const sheetName = "Enter the Sheet's name of items want to be auto uploads!"; const ss = SpreadsheetApp.openById(id); const sheet = ss.getSheetByName(sheetName); const range = sheet.getDataRange().getValues(); // i recommend you do a sheet only to set data'll be upload const choiceValues = [...new Set(range.map(row => row[0]).filter(value => value))]; const form = FormApp.openById("Enter your Forms ID here!"); const items = form.getItems(); for (var i in items) { if (items[i].getTitle() == "Set here the question name of Forms!") { items[i].asListItem().setChoiceValues(choiceValues); return; } } Logger.log("Nothing found..."); }
The code was to update the data that would feed a weekly report.
Find more information in the repository.
The above is the detailed content of Automation for Google Forms. For more information, please follow other related articles on the PHP Chinese website!