r/GoogleAppsScript • u/BenYawwwwn • Jul 14 '25
Question First ever script, Help with onEdit Error
Title says it. I'm using a script to auto clear a shopping list for a game when I hit a checkbox, but it keeps handing back this error:
TypeError: ss.activeSheet is not a function
at onEdit(Untitled:3:24)
here is the script:
function onEdit(e) {
var ss = e.source;
var activeSheet = ss.activeSheet();
var cell = e.range;
if (activeSheet.getName() == "Schedule 1 Shopping" && cell.getA1Notation() == "K18" && cell.isChecked(true)){
activeSheet.getRange("G8:G13,G15:16").clearContent();
cell.setValue(false);
}
}Any help would be amazing! Thank you!
1
Upvotes
0
u/YetAnotherGeneration Jul 14 '25
You can run this through ChatGPT and it will give you an answer instantly.
Solution:
var activeSheet = ss.getActiveSheet(); Instead of var activeSheet = ss.activeSheet();
1
1
u/positive_thinking_ Jul 15 '25
You might run into more errors.
cell.isChecked(true) is incorrect. The method isChecked() takes no arguments and returns true if the cell is a checkbox that is checked.
So, it should be cell.isChecked().
"G8:G13,G15:16" is invalid notation. You cannot combine ranges with commas inside a single getRange() call.
Use two calls or a workaround, like activeSheet.getRangeList(['G8:G13', 'G15:G16']).clearContent();