How do i change/update validation of question (item) in google form with apps scripts

心不动则不痛 提交于 2021-01-28 10:51:53

问题


I have already try to update text validation for my class with google apps scripts but it say "textItem.setValidation is not a function". Please help me

function setPass() {
var form = FormApp.openById('Google Form ID');
var textItem = form.getItemById(Question ID);
var textValidation = FormApp.createTextValidation()
.requireNumberEqualTo(22111)
.build();
textItem.setValidation(textValidation)

回答1:


You are very close to update the question, you only need to add the method .asTextItem() after getting the item by id. The final code should look like this:

function setPass() {
var form = FormApp.openById('Google Form ID');
var textItem = form.getItemById(Question ID).asTextItem();
var textValidation = FormApp.createTextValidation()
.requireNumberEqualTo(22111)
.build();
textItem.setValidation(textValidation)

Don't hesitate to ask me any question if you need further help.



来源:https://stackoverflow.com/questions/61885784/how-do-i-change-update-validation-of-question-item-in-google-form-with-apps-sc

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