Namokonov

update form from ss

Aug 4th, 2021
621
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var formUrl = "https://docs.google.com/forms/d/1lNsJIzQsm09Hp5Is9jHE3CwrXWW9IdwX666HIoSOWG8/edit";
  2.  
  3. function main() {
  4.   let wsData = SpreadsheetApp.getActive().getSheetByName("Клиент");
  5.   let form = FormApp.openByUrl(formUrl);
  6.   let formItems = form.getItems();
  7.   let data = wsData.getDataRange().getValues();
  8.  
  9.   for (x in data[0]) {
  10.     let header = data[0][x];
  11.     Logger.log(header);
  12.     let formFilter = formItems.filter(g => g.getTitle() == header)
  13.     if (formFilter.length) {
  14.       let v = data.map(col => col[x]).slice(1).filter(t => t);
  15.       Logger.log(v);
  16.       form.getItemById(formFilter[0].getId()).asMultipleChoiceItem().setChoiceValues(v)
  17.     }
  18.   }
  19. }
RAW Paste Data