问题
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