google-apps-script - 可以以编程方式修改现有的 Google 文档表单吗?
问题描述
我有一个预先存在的表单,以交互方式创建。看来(根据我的实验)如果以编程方式创建表单可以以编程方式修改,但如果以交互方式创建则不能。
背景涉及维护:如果表单/电子表格所有者想要修改表单,正确更新相关的选项卡/工作表是他们头上的事。有一些复选框列表需要随着时间的推移而更新。我正在编写一个脚本,用户可以在其中为复选框项目添加标签,它会根据需要更新所有选项卡/工作表......但我试图在表单中添加一个复选框。
“var form = FormApp.getActiveForm();” 只返回空值。“openById”和:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var form = FormApp.openByUrl(ss.getFormUrl());
似乎可以工作,但是当我遍历“表单”时,我得到了一些奇怪的结果。例如:
for each (var i in form.getItems(FormApp.ItemType.CHECKBOX)) {
Logger.log(i);
for each (var j in i) {
Logger.log(j);
}
}
虽然“表单”包含许多“项目”对象,但每个项目似乎都包含 Item 类的源代码:
> [19-03-15 07:53:57:329 HST] Item
> [19-03-15 07:53:57:330 HST] function asPageBreakItem() {/*
> */} [19-03-15 07:53:57:331 HST] function asParagraphTextItem() {/*
> */} [19-03-15 07:53:57:331 HST] function getHelpText() {/*
> */} [19-03-15 07:53:57:332 HST] function getIndex() {/*
> */} [19-03-15 07:53:57:332 HST] function asTimeItem() {/*
> */} [19-03-15 07:53:57:332 HST] function asImageItem() {/*
> */} [19-03-15 07:53:57:333 HST] function asScaleItem() {/*
> */} [19-03-15 07:53:57:333 HST] function getId() {/*
> */} [19-03-15 07:53:57:333 HST] function asMultipleChoiceItem() {/*
> */} [19-03-15 07:53:57:334 HST] function getTitle() {/*
> */} [19-03-15 07:53:57:334 HST] function asGridItem() {/*
> */} [19-03-15 07:53:57:335 HST] function asDurationItem() {/*
> */} [19-03-15 07:53:57:335 HST] function asVideoItem() {/*
> */} [19-03-15 07:53:57:335 HST] function asTextItem() {/*
> */} [19-03-15 07:53:57:336 HST] function asDateTimeItem() {/*
> */} [19-03-15 07:53:57:336 HST] function setTitle() {/*
> */} [19-03-15 07:53:57:337 HST] function duplicate() {/*
> */} [19-03-15 07:53:57:337 HST] function asCheckboxItem() {/*
> */} [19-03-15 07:53:57:337 HST] function setHelpText() {/*
> */} [19-03-15 07:53:57:338 HST] function asDateItem() {/*
> */} [19-03-15 07:53:57:338 HST] function getType() {/*
> */} [19-03-15 07:53:57:339 HST] function asSectionHeaderItem() {/*
> */} [19-03-15 07:53:57:339 HST] function toString() {/*
> */} [19-03-15 07:53:57:339 HST] function asCheckboxGridItem() {/*
> */} [19-03-15 07:53:57:340 HST] function asListItem() {/*
> */}
希望我刚刚离开杂草,我可以修改现有的复选框......有人可以指出我正确的方向吗?
解决方案
您是否考虑过在电子表格中维护选项卡列表,然后从电子表格中填充表单?
推荐阅读
- angular - 使用 Angular 6 构建 App :ag-grid 后出错
- docker - 可以看到 Docker 容器中的文件,但无法访问它
- crud - Symfony4 MakerBundle 自己的 Crud Maker
- node.js - 在节点 js 中的 Firebase Admin SDK 中更新或设置会导致无限回调
- angular - 角度cli 6,ng测试不起作用
- reactjs - 如何在 React js 中添加动态 CSS
- sql - Microsoft SQL Server Management Studio 连接日志
- mysql - SQL 替换列的每个字符串的一些文本
- fft - FFTW 非对称逆变换 c2r
- java - 确定按钮在 vaadin 中不起作用