0
votes

I'm a bit new to Google App script, but I recognize it's essentially javascript with google libraries and the like.

As for my problem, i'm trying to make a script that calls a function with the values of an entire row upon edit in a certain range. To set the range "boundary" I've currently got this:

function onEdit(e){
  if (
    e.range.columnStart >= 3 &&
    e.range.columnEnd <= 9 &&
    e.range.rowStart >= 13 &&
    e.range.rowEnd <= 101
  )
  {
    Logger.log("Edit in range");
    var editRow = (e.range.rowStart, e.range.rowEnd)
    Logger.log("Edit Row: " + editRow);
  }
  else
  {
    Logger.Log("Edit outside of Range");
  }
}

This currently works and logs if the edit is in the specified range, and also logs which row the edit has been made in. What I need to figure out, is how to get the values of the entire row of that edited cell so I can pass it to a function.

How would I go about doing that?

1
E.range.getvalue or e.range.getvalues, please tryuser11982798

1 Answers

1
votes

You want to get the values for the edited range.

You have already used Event objects to identify and evaluate the limits of the edited range. You can use that same information to:

  • getSheet()
  • getRange(row, column, numRows, numColumns), and then
  • getValues() from the range

function onEdit(e){



  if (
    e.range.columnStart >= 3 &&
    e.range.columnEnd <= 9 &&
    e.range.rowStart >= 13 &&
    e.range.rowEnd <= 101
  )
  {
    Logger.log("Edit in range");
    var sheet = e.range.getSheet();
    var editRowRange = sheet.getrange(e.range.rowStart,e.range.columnStart,e.range.rowEnd-e.range.rowStart+1,e.range.columnEnd-e.range.columnStart+1);
    var editRow = editRowRange.getvalues();
    Logger.log("Edit Row: " + editRow);
  }
  else
  {
    Logger.Log("Edit outside of Range");
  }
}