![](/img/trans.png)
[英]Manipulate google form associated with a google sheet from app script in that sheet
[英]Google app script to update Form from Sheet
我正在嘗試使用 Google 表格中的一行數據填充 Google 表單多項選擇。 我可以將行文本放入一個數組中,但是當我使用 method.setChoiceValues() 時,我得到了一個:
Exception: Invalid conversion for item type: TEXT. (line 36, file "PopulateBudgetCategories")
根據 Google 文檔,這種方法接收到一個 String[],但失敗了,拋出了同樣的期望,即使使用以下代碼:
studentNames = ['🚗⛽ Car', '🚑 Healthcare', '📱 Mobile phones'];
formExpenseTypes.asListItem().setChoiceValues(studentNames);
有沒有人知道如何解決這個問題?
謝謝。
formExpenseTypes
是TEXT
類型的項目asListItem()
表示您正在將項目作為下拉問題檢索,但是如果您的問題在創建時不是下拉問題asMultipleChoiceItem()
,而不是asListItem()
樣本:
function myFunction() {
var form = FormApp.getActiveForm();
form.addMultipleChoiceItem();
var items = form.getItems();
var formExpenseTypes = items[items.length-1];
studentNames = ['🚗⛽ Car', '🚑 Healthcare', '📱 Mobile phones'];
formExpenseTypes.asMultipleChoiceItem().setChoiceValues(studentNames);
}
對不起,這都是我的錯誤。 在其中一個編輯中,我認為表單控件的 ID 更改了順序,我實際上是在嘗試將選項添加到文本問題中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.