As documentation says, the "on change" trigger includes EDIT among other kinds of changes:
The type of change (EDIT, INSERT_ROW, INSERT_COLUMN, REMOVE_ROW, REMOVE_COLUMN, INSERT_GRID, REMOVE_GRID, FORMAT, or OTHER)
If you wanted to not execute code when the change is an edit, use a condition such as
function onmychange(e) {
if (e.changeType != "EDIT") {
Browser.msgBox("Change that is not an edit");
}
}
That said, all the actions you mentioned (CHANGES a value in a cell that already has a value, adds a NEW value in a cell that has no value, DELETES a value in a cell) are Edits, so onEdit is the only trigger you need.
If the goal is to find what kind of an edit was made, use e.value and e.oldValue. The former has some quirks when using simple trigger onEdit(e):
- If a user inputs "foo" directly (includes pasting from an external source): e.value is "foo"
- If a user pastes "foo" that was copied from elsewhere in the sheet: e.value is
{}, empty object.
- If a user clears out the cell that had "foo" previously: e.value is the object
{"oldValue":"foo"}
(If one uses an installable trigger running on edit, then in cases 2 and 3 there is no property "value" in the event object at all.)
In order to get around the aforementioned quirks, I use the following:
function onEdit(e) {
var newValue = (typeof e.value == "object" ? e.range.getValue() : e.value);
//
}
which makes sure that newValue has the new value that is now in the cell.
You may want to observe the behavior of triggers by using the following logging trigger:
function onEdit(e) {
e.range.offset(0, 1).setValue(JSON.stringify(e));
}
When i add value in blank col BOTH fires Ive tried to trigger on change and edit in triggers, but i dont know why this happends, im aware of trigger types terrywb – Asim Jul 31 '17 at 18:51