Skip to content

Instantly share code, notes, and snippets.

@bfodeke
Created June 2, 2023 16:37
Show Gist options
  • Save bfodeke/97bac4031a75f77a8a27139065c533c0 to your computer and use it in GitHub Desktop.
Save bfodeke/97bac4031a75f77a8a27139065c533c0 to your computer and use it in GitHub Desktop.
AppsScript to create google form programmatically. You will still need to connect the form to an existing sheet or create a new spreadsheet
function createForm() {
// Create a new Form.
var form = FormApp.create('Issue Priority Assessment');
var questions = [
{
title: 'Issue Impact',
options: [
'No impact on production today',
'Partial impact on production today',
'Complete failure of a function or feature'
]
},
{
title: 'Data Risk',
options: [
'No risk of data loss or compromise',
'Possible risk of data loss or compromise',
'High risk of data loss or compromise'
]
},
// ... Other questions
];
for (var i = 0; i < questions.length; i++) {
var question = form.addMultipleChoiceItem();
question.setTitle(questions[i].title);
var choices = [];
for (var j = 0; j < questions[i].options.length; j++) {
choices.push(question.createChoice(questions[i].options[j]));
}
question.setChoices(choices);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment