I need to limit the function onEdit()
to fire only when changes are made within the specific range. Users selects a value in column B and column A is opopulated with a specific value.
Although the funciton below seems to work as desired, when run from within the Apps Editor, it throws an error:
TypeError: Cannot read property "source" from undefined.
which apparently refers to e.source.getSheetName
line
function onEdit(e) {
if (
e.source.getSheetName() == "Activity" &&
e.range.columnStart == 2 &&
e.range.columnEnd == 2 &&
e.range.rowStart >= 2 &&
e.range.rowEnd <= 100
) {
e.value !=='' ? e.range.offset(0,-1).setValue(caseID()) : null
};
};
I am not sure if this could be ignored, since the function works (inserts result of caseID function in column A, when value is changed in column B)? Thank you in advance,