If I have a sheet with 20 separate onEdit() scripts running, would any problems arise if 2 unique edits are made at approximately the same time by different users? More specifically:
1) What is the time resolution for an edit to be recorded? For instance, the probability of two people editing at the same millisecond is very small, but perhaps within the same second may not be terribly improbable. If two people edit in the same second, would it fail to recognize these as separate edits? Or can it clearly recognize every edit as a unique event regardless of how closely they happened?
2) If one onEdit() script is triggered and does not finish before another edit occurs, would this cause a failure in the second edit to be properly evaluated?
3) I have about 20 scripts running on a sheet with about 20 tabs and about 7 users on it at any given time. Are there any other problems you foresee that would cause some onEdit() scripts to not work?
My script checks to see if the edit was made in column x on sheet x and if so, copies it to the next sheet and deletes the row from the first sheet. It is currently failing about 30% of the time. I don't know why. It hasn't done this in the past.
My code looks like this:
function onEdit(e){
var edited_range = e.range;
var edited_row = edited_range.getRow();
var activeSheet = e.source.getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source_sheet = ss.getSheetByName("N.Arb Pitches");
var target_sheet = ss.getSheetByName("N.Arb In Progress");
var last_row = target_sheet.getLastRow();
var range_values = target_sheet.getRange("A1:A").getValues();
var range_length = range_values.filter(String).length + 1;
var target_range = target_sheet.getRange(range_length,1);
if (activeSheet.getName() == "N.Arb Pitches") {
if (edited_range.getColumn() == 13) {
if (edited_range.getValue().toLowerCase() == "yes") {
target_sheet.insertRowAfter(last_row);
source_sheet.getRange(edited_row,1,1,12).copyTo(target_range);
source_sheet.deleteRow(edited_row) }}};
}
There is only 1 onEdit(e) function in each project, and I have this many projects in my sheet. Each project has a function like the one above but with sheet names changed.
LockService
– TheMaster