Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to populate a google form from a google spreadsheet?

I'd like to create a form that uses the data from the spreadsheet, so that it's dynamic. Is it possible to do this? I haven't been able to find anywhere that describes how, or any examples.

All that seems possible is to populate a spreadsheet from a form, which I'll also use but its not the primary concern here.

like image 710
George Avatar asked Sep 08 '09 13:09

George


People also ask

How do I populate data from Google Sheets to Google Forms?

Go to the Insert menu in Google Sheets, choose drawing and pick any shape. You can also add overlay text to the shape. Once the shape is placed on the spreadsheet canvas, click the menu, choose assign script and type populateGoogleForms . That's it.

Can you link a google sheet to a Google Form?

That's great for quick form results, but for more tools to analyze answers, you can link your form to a Google Sheets spreadsheet. Just click the green Sheets icon in the Responses tab or click Select response destination in the menu, then create a new spreadsheet or select an existing one to store the answers.

Can you import Google Sheets into forms?

“Form Builder for Sheets” helps you to build Google Form in a very simple and fast way by importing fields/questions/quiz from existing Google Sheets.


2 Answers

Google Apps Scripts.. finally a well documented way of generating Google forms programmatically. https://developers.google.com/apps-script/reference/forms/

like image 180
Orbits Irth Avatar answered Nov 15 '22 09:11

Orbits Irth


Yes it is. Use a Form script and update the information from the spreadsheet using a trigger on the FORM OPEN. Here is an example that gets data from two different sheets and insert data in a combo box and into a multiple choice control.

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')

}
like image 24
akitaguy Avatar answered Nov 15 '22 07:11

akitaguy