-1
function fill_complex() {
  var wrkBK = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht = wrkBK.getSheetByName("LIST");

  var FormURL = "https://docs.google.com/forms/d/e/1FAIpQLSdIebPKY4Qe1LzV_oPkpRCHtfbHgurxLGmjZDKe_FiHMa25Rg/formResponse?&pageHistory=0,1,2";

  var NoOfRows = 11;

  for (var i = 2; i <= NoOfRows; i++) {
    var Nama = wrkSht.getRange("A" + i).getDisplayValue();
    var Tarikh = wrkSht.getRange("B" + i).getDisplayValue();
    var Kelas = wrkSht.getRange("C" + i).getDisplayValue();
    var Tajuk = wrkSht.getRange("D" + i).getDisplayValue();
    var Bahasa = wrkSht.getRange("E" + i).getDisplayValue();
    var Jenis = wrkSht.getRange("F" + i).getDisplayValue();
    var Pilih = wrkSht.getRange("G" + i).getDisplayValue();
    var Rumusan = wrkSht.getRange("H" + i).getDisplayValue();
    var Aktiviti = wrkSht.getRange("I" + i).getDisplayValue();

    var FormData =
      "&entry.1282223098=" + encodeURIComponent(Nama) +
      "&entry.2007435108=" + encodeURIComponent(Tarikh) +
      "&entry.1658433344=" + encodeURIComponent(Kelas) +
      "&entry.1084037501=" + encodeURIComponent(Tajuk) +
      "&entry.646512950=" + encodeURIComponent(Bahasa) +
      "&entry.1231079028=" + encodeURIComponent(Jenis) +
      "&entry.689435694=" + encodeURIComponent(Pilih) +
      "&entry.573088649=" + encodeURIComponent(Rumusan) +
      "&entry.1263929889=" + encodeURIComponent(Aktiviti);

    var FinalURL = FormURL + FormData;

    var Options = {
      "method": "post"
    };

    UrlFetchApp.fetch(FinalURL, Options);
  }
}

This is the error message i got

Exception: Request failed for https://docs.google.com returned code 400. Truncated server response: <!DOCTYPE html><html lang="en" class="HB1eCd-UMrnmb"><head><link rel="shortcut icon" sizes="16x16" href="https://ssl.gstatic.com/docs/spreadsheets/... (use muteHttpExceptions option to examine full response)

fill_complex

@ Code.gs:37

My web Properties :

Section 1 :

entry.1282223098 (Name/Nama)

entry.2007435108 (Date/Tarikh)

entry.1658433344 (Class/Kelas)

entry.1084037501 (Title/Tajuk)

entry.646512950 (Language/Bahasa)

entry.1231079028 (Type of book/Jenis bacaan) - Bukan Buku (Poster)

Section 2 :

entry.689435694 (Sila pilih/Pick) - POSTER

Section 3 :

entry.573088649 (Summary/Rumusan)

entry.1263929889

(Activity/Aktiviti) - MENGEJA

Mr Shane
  • 520
  • 5
  • 18
  • It appears that you are trying to create "prefilled links" from existing data in a Sheets file. You may find it less troublesome to do this task with formulas instead. – Mr Shane Aug 19 '23 at 19:01
  • The answer in [Is it possible to 'prefill' a google form using data from a google spreadsheet?](https://stackoverflow.com/a/20110656/1330560) is an example of simplified, formula-driven approach suggested by @MrShane. – Tedinoz Aug 20 '23 at 01:22

0 Answers0