samedi 11 juin 2022

Can't get checkboxes to work google sheets script

I have little to no experience with google scripts, and I find myself in a pickle. I want to execute a script when a checkbox is checked. I got this working. The problem is i can't make the script take into account other checkboxes - say i have 3 options for the script -> log ALL, log only fruits and add the store. It runs when i click RUN, but it won't take into account my "log fruit" checkbox. At the end it will set the checkbox that runs the script back to FALSE.

function onEdit(e) {
  const sh = e.range.getSheet();
  if (e.range.columnStart == 6 && e.range.columnEnd == 6 && e.range.rowStart == 7 && e.range.rowEnd == 7 && e.value == "TRUE") {
    if (e.range.columnStart == 6 && e.range.columnEnd == 6 && e.range.rowStart == 4 && e.range.rowEnd == 4 && e.value == "TRUE") {
      sh.getRange(e.range.rowStart, 6).setValue(10);
    }
    sh.getRange(e.range.rowStart, 8).setValue(20);
    sh.getRange(e.range.rowStart, 6).setValue("FALSE");
  }
}

Any ideas ?

https://docs.google.com/spreadsheets/d/1BtDoO3QIGaiZxUYTld5Si8die1W-O_1FiqczqgN8diI/edit#gid=1776658601




Aucun commentaire:

Enregistrer un commentaire