Skip to content

Instantly share code, notes, and snippets.

@neno-tech
Created January 4, 2021 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neno-tech/7eeaf564b03b8e8aaecdeb72078aab80 to your computer and use it in GitHub Desktop.
Save neno-tech/7eeaf564b03b8e8aaecdeb72078aab80 to your computer and use it in GitHub Desktop.
Code ทำระบบเลือกประธานนักเรียน
var sheetId = "xxx"
var formId = "xxx"
function myFunction() {
var ss = SpreadsheetApp.openById(sheetId)
var sheet = ss.getSheetByName("xxx")
var form = FormApp.openById(formId)
var data = [...new Set(sheet.getDataRange().getDisplayValues().map(row=> row[1]))].join('|')
var item = form.getItems().filter(item=>item.getTitle() == 'รหัสนักเรียน')[0].asTextItem()
var pattern = `(${data})`
var textval = FormApp.createTextValidation().setHelpText("คุณได้ใช้สิทธิ์เลือกประธานไปแล้ว").requireTextDoesNotMatchPattern(pattern).build()
item.setValidation(textval)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment