Im trying to move a row from one sheet to another using a script.

The problem: i'm using a phone app as the input to the spreadsheet, but for some reason it doesn't activate the "edit" trigger?

Here is my script:

function onEdit(event) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = event.source.getActiveSheet();
  var r = event.source.getActiveRange();

  if(s.getName() =="Sheet1" && r.getColumn() == 14 && r.getValue() =="Finished") {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = ss.getSheetByName("Finished");
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
  • 1
    I tried to make your question a bit easier to read by rewording and improving the code indentation. Please review my changes if they meet your intent. – GhostCat Sep 3 at 17:53
  • Does it work on a desktop? Simple triggers, like onEdit, need to be authorized before they can access particular classes or methods. – Brian Sep 3 at 18:47
  • Yes, it does work when it is entered normally from a desktop. – chris kester Sep 3 at 20:25
  • Yes,TypeError: Cannot read property "source" from undefined. (line 3, file "Code") – chris kester Sep 3 at 21:35
  • That makes sense. If the problem is that the script is not "seeing" the edit from the mobile app. Could i use a time trigger every minute to check for "Finished" in the column? Im not sure how to do that. – chris kester Sep 3 at 22:52

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.