I have the following function running in Apps Script, however the onEdit function is only called via manual edits. It does not work when I edit the sheet using the API. Here is the function:
/** * Automatically sorts the 8th column (not the header row) Ascending. */function onEdit(event){ var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var editedCell = sheet.getActiveCell(); var columnToSortBy = 8; var startRow = 2; var startColumn = 1; var range = sheet.getRange(startRow,startColumn,sheet.getLastRow()-startRow+1,sheet.getLastColumn()-startColumn+1); range.sort( { column : columnToSortBy, ascending: true } );}Edit: A commenter suggested that this question may be similar to another question, see comment below. However that question is discussing the difference between two functions, neither of which solve my issue, this question is asking about a functionality that neither of those functions provide.