Run appscript when button clicked

I create reminder like birtday reminder using app script, it worked fine in app script.

function bookReminder(){
let spreadsheet = SpreadsheetApp.openById(‘xxxxx’);
sheet = spreadsheet.getSheetByName(‘xxxxx’);
lastRow = sheet.getLastRow();
lastCol = sheet.getLastColumn();
data = sheet.getRange(2, 1, lastRow-1, lastCol).getValues();

let myEmail = ‘xxxx’

for (let index = 0; index < lastRow-1; index++){

 let tanggal_kembali = data[index][4]
 tanggal_kembali = Utilities.formatDate(tanggal_kembali, 'GMT+8', 'MM/dd');
 let today = new Date();
 today = Utilities.formatDate(today, 'GMT+8', 'MM/dd');
 
 if (tanggal_kembali == today){
     MailApp.sendEmail({
     to: myEmail,
     subject: "BATAS PENGEMBALIAN BUKU KELAS" + " " + data[index][1],
     htmlBody: '<b>NAMA:</b>'+"<br/>"
              + data[index][0]+"<br/>"
              +"<br/>"
              +'<b>KELAS:</b>'+"<br/>"
              + data[index][1]+"<br/>"
              +"<br/>"
              +'<b>JUDUL BUKU :</b>'+"<br/>"
              + data[index][2]
     });
}

}
}

How to auto run this script every button clicked in kodular?
please help

1 Like

I have the same trouble :smiling_face_with_tear:

You probably want to use a doGet(e) or doPost(e) function in order to call the script as a web app from Kodular

I need to execute this function from kodular :sweat_smile: but i dont know
function saveAsSpreadsheet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var destFolder = DriveApp.getFolderById(“ID FOLDER”);
DriveApp.getFileById(sheet.getId()).makeCopy(“desired file name”, destFolder);
}