Can I fill out a google form from google spreadsheet?

I would like to create a form that uses data from a spreadsheet so that it is dynamic. Is it possible to do this? I could not find anywhere that describes how or any examples.

All that seems possible is to fill out a table from a form, which I will also use, but this is not the main problem here.

+3
source share
4 answers

Google Apps Scripts .. Finally, a well-documented way to create Google forms programmatically. https://developers.google.com/apps-script/reference/forms/

+4
source

, . script , FORM OPEN. , .

function getNewNames(){
  var form = FormApp.getActiveForm();
  var items = form.getItems();

  var ss = SpreadsheetApp.openByUrl(
     'https://docs.google.com/spreadsheets/d/YOURDOCSNAMEHERE/edit');
    var assSheet1 = ss.getSheetByName('Sheet1');
    var assValues = assSheet1.getDataRange().getValues();
    var values = assValues.slice(1);
    var valSort = values.sort();

  var ss2 = SpreadsheetApp.openByUrl(
     'https://docs.google.com/spreadsheets/d/DOCSNAMEHERE/edit');
     var playerSheet1 = ss2.getSheets()[0];
     var playerValues = playerSheet1.getDataRange().getValues(); 
     var player = playerValues.slice(0);
     var plySort = player.sort();

  var names = [];

  for(var p = 0; p < plySort.length; p++){
    names.push(plySort[p][0])
  }

  var pList = items[0].asListItem();
  pList.setChoiceValues(names).setRequired(true).setHelpText('Please Select Player Name')

  var areas = [];
  for (var i = 0; i < valSort.length; i++) {
      areas.push(valSort[i][1])
    }

  var aList = items[1].asMultipleChoiceItem();
      aList.setChoiceValues(areas).setRequired(true).setHelpText('Select Area of Assessment')

}
+3

, FormRanger. , , . . . : , , Formranger , .

+1
source

There is currently a function request for adding a forms API that will allow you to create, retrieve, update, and delete a spreadsheet form. Although functionality does not exist at the moment, if and when it happens, you can associate spreadsheet data with data using the form API and spreadsheet data API. function request here .

0
source

Source: https://habr.com/ru/post/1717147/


All Articles