@john17 (章男 田中)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

GASでプルダウンメニューをスプレッドシートから引用するエラー対処

Q&A

Closed

解決したいこと

Gooleフォームの回答をスプレッドシートから読み込んだ項目をプルダウンで選択したいと思ってます。
次の様なコードを書いたのですが、エラーがでてしまい解消方法がわかりません。
初歩的なことかと思いますが、解決方法を発見できません。
解決方法を教えてください。

〜記載したコード〜〜〜〜〜〜〜〜〜〜

function setNameList() {
const ss = SpreadsheetApp.openById("ID");
const nameSheet = ss.getSheetByName("シート名A");
const nameList = nameSheet.getRange(2,1,nameSheet.getLastRow()-1).getValues();
const form = FormApp.getActiveForm();
var items = form.getItems(FormApp.ItemType.LIST);
items.forEach(function(item){
if(item.getTitle() == "質問名") {
var listItemQuestion = item.asListItem();
var choices =[];
nameList.forEach(function(names){
if(names != ""){
choices.push(listItemQuestion.createChoice(names));
}
});
listItemQuestion.setChoices(choices);
}
});

}
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜

発生している問題・エラー

Exception: Questions cannot have duplicate choice values.

image.png

自分で試したこと

変数名かな?とも思いましたが、まだまだ解決能力がなくわかりません...

0 likes

No Answers yet.

Your answer might help someone💌