Script to update Google Form from Spreadsheet

痴心易碎 提交于 2019-12-24 15:39:29

问题


Here's my problem:

I can't seem to piece this info together nor find it anywhere even though it seems simple enough. When I find help, they just tell me to enter it manually (but my users can't be trusted) or make a new form (not an option).

What I need is to be able to keep:

  • the same google form
  • it's ID and link to the same spreadsheet
  • the same 20 "paragraph text" questions (titles remain the same).

There can't be any new questions or anything that would change the name or layout of the response destination page in the spreadsheet.

However, what I want is:

  • to update the help text below these questions from twenty cells in the spreadsheet. If my cells are from a range called questions!b2:b19 in the same spreadsheet, how do I use a script to take their contents and write over and update the help text in these paragraph questions on the google form?

Any help would be greatly appreciated.


回答1:


It might be easiest to create your form in AppScript. With your form created, you can then use AppScript to access your spreadsheet. Read the information from the sheet and use it to create the help text on your questions with setHelpText.

Here's a basic sample.

var form = FormApp.create('New Form');
var item = form.addCheckboxItem();
var ss = SpreadsheetApp.openById("<ID>");
var val = ss.getRange(<RANGE>).getValue();

item.setTitle('Question');
item.setHelpText(val);
item.setChoices([
        item.createChoice('ONE'),
        item.createChoice('TWO'),
        item.createChoice('THREE')
    ]);


来源:https://stackoverflow.com/questions/29597066/script-to-update-google-form-from-spreadsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!