Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Custom function to move and delete a row isn't doing anything

$
0
0

I have a script bound to my Google spreadsheet with a simple onEdit(e) trigger that isn't working.

The script is supposed to move the edited row to Closed Cases, then delete the original row, if the following conditions in the active sheet are all true:

  1. The active sheet is named 11th Grade
  2. The edited cell is in the checkbox Column 14 / N
  3. The checkbox is selected / true
  4. Column 4 / D contains the value "Success"

When I make changes to 11th Grade the script always completes successfully but the row is never moved or deleted.

function onEdit(e) {  var ss = e.source;  var activatedSheetName = ss.getActiveSheet().getName();  var activatedCell = ss.getActiveSelection();  var activatedCellRow = activatedCell.getRow();  var activatedCellColumn = activatedCell.getColumn();  var activatedCellValue = activatedCell.getValue();  var input = ss.getSheetByName("11th Grade"); // source sheet  var closed = ss.getSheetByName("Closed Cases"); // target sheet  // if the value in column D is "Success", move the row to target sheet  if (activatedSheetName == input.getName() && activatedCellColumn == 14 && activatedCellValue == "True") {    // insert a new row at the second row of the target sheet    closedlosed.insertRows(2,1);    // move the entire source row to the second row of target sheet    var rangeToMove = input.getRange(/*startRow*/ activatedCellRow, /*startColumn*/ 1, /*numRows*/ 1, /*numColumns*/ input.getMaxColumns());    rangeToMove.moveTo(closedlosed.getRange("A2"));    // delete row from source sheet    input.deleteRows(activatedCellRow,1);  }}

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>