Search code examples
javascriptgoogle-apps-scriptgoogle-sheetsgoogle-forms

Prefill Questions on a Google Form


I know how to prefill a Google form with answers/responses that are populated on a Google Sheet,

I wondered if there is a way to do this in reverse, so prefil a Google Form with not only the answers/responses but also the questions?

For example. Create a hyperlink form which populates Q1,Q3,Q5,Q6 and the response aligned, excluding Q2,Q4,Q7,Q8,Q9,Q10 from the form as they are blank

Appreciate any help on this

Thanks

enter image description here


Solution

  • Yes, you can achieve that by creating a Google Form programmatically using Apps Script. You can use SpreadsheetApp class for reading/manipulating the sheet and FormApp class to create and manipulate the Google Form.

    You'd first need to get the values from the sheet using for example getValues():

    var values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getValues();
    

    And use those value to create the form using the create() method:

    var form = FormApp.create('Form Name');
    

    Then you'll have a Form object to which you can add question items depending on each question type you wish.

    You can guide yourself from this other answer as well.