Apps Script에서 FormApp를 사용하여 업데이트 할 양식 객체에 액세스 할 수 있습니다.
다음은 "목록에서 선택"개체를 업데이트하는 예입니다. 각 제출 후에 양식을 갱신하려는 경우 컨테이너 기반 트리거 "양식 제출시"를 사용하여 updateList 함수를 호출 할 수 있습니다.
function updateList(){
var form = FormApp.openById(formId);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
// get the range of values to update in the form
var data = sheet.getRange(2,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
var listItemsToAdd = [];
for(s in data){
if(logic to define if to add to the form){
listItemsToAdd.push(data[s][0]);
}
}
// get all the list items in the form
var list = form.getItems(FormApp.ItemType.LIST);
// grab the first list item in the array of the form's list items
var item = list[0].asListItem();
// set the options to the array just created
item.setChoiceValues(listItemsToAdd);
}
그러나 'for (s in data)'는 배열을 순환하지 마십시오. –
@Cyrus Loree : Ok,하지만 이것에 대한 질문을하고 싶습니다. 탐색 유형으로 for 루프 내의 값을 어떻게 설정합니까? ([이 예제와 같이] (https://developers.google.com/apps-script/reference/forms/choice) –
다른 대화라고 생각합니다. 새로운 질문을 게시하면 기꺼이 자세히 설명하겠습니다. 짧은 대답은 PageNavigationType 열거 대신 페이지 나누기 항목을 전달한다는 것입니다. E.G. var anotherPage = form.addPageBreakItem(). setTitle ('이동할 다른 페이지'); ... item.createChoice ('내 새 페이지', 다른 페이지), item.createChoice ('Dogs', FormApp.PageNavigationType.RESTART) ]); –