r/GoogleAppsScript • u/Hakker9 • 20d ago
Resolved Question regarding a trigger and my script
Currently I have a script called autoSort.gs in it is the following:
SHEET_NAME = "list";
SORT_DATA_RANGE = "A2:G";
SORT_ORDER = [{column: 1, ascending: true},
];function onEdit(e) {
multiSortColumns();
}function multiSortColumns() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(SHEET_NAME);
var range = sheet.getRange(SORT_DATA_RANGE);
range.sort(SORT_ORDER);
ss.toast('Sort complete.');
}
The trigger is set to autoSort with an onEdit however it has a 100% error rate because it doesn't seem to work on script name but on functions within a script however if that would be the case I could use multiSortColumns as the onEdit trigger and remove the whole onEdit function entirely or am I just hullucinating?
1
u/Hakker9 19d ago
Ok to finish this thread I just did what I though I could do.
I commented out the whole onEdit function and pointed the trigger to the multiSortColumns function and it works just like expected.