Search code examples
google-apps-scriptdefaultgoogle-forms

Google Apps scripts: set a defaut answer during the creation of the form


I just started working with google app script in order to create a simple google form composed by several questions with the same structure: image question multiple-choice-item. In this example I load the images from a google drive

 var folder = DriveApp.getFolderById(<gdrive id>);
 var files = folder.getFiles();
 while (files.hasNext()) {
    img = files.next();
    Logger.log(img)
    form.addImageItem()
      .setImage(img)
      .setTitle(img.toString());

    form.addMultipleChoiceItem()
     .setTitle(img.toString())
     .setChoiceValues(['Yes','No', 'Maybe'])
     .setRequired(true);
}

There is a way to preselect the all answers to 'No'? In other words, can I preset a choise to a certain value? Thanks


Solution

  • From the documentation there is currently no defined property for a "default answer" for a MultipleChoiceItem or Choice item class in a Form object. Thus all respondents will have no premarked answers when they open the form.

    References:

    Class MultipleChoiceItem

    Class Choice