Double the variables in move script (Google)

For my work I am trying to automatically move a marked line to a 'Historie' sheet. I have currently managed to follow an example and use 1 variable (see copy). Now I want 2 variables. Instead of just column K -> Completed, I also want to add that column J needs to be True!

function onEdit(event){
  var url = "https://docs.google.com/spreadsheets/d/1per7L2wPkMKrzVgv5npQ-2RQ8fkWzslo09Ntlzy4qAs/edit?ts=6034e66e#gid=0";
  var source_sheet_name = "Werklijst";
  var target_sheet_name = "Historie";
  var columnLetter = "J";
  
  var ss= SpreadsheetApp.openByUrl(url);
  var source_sheet = ss.getSheetByName(source_sheet_name);
  var target_sheet = ss.getSheetByName(target_sheet_name);
  var source_range = source_sheet.getRange(columnLetter+":"+columnLetter).getValues();
  
  for(var i = source_range.length-1; i >= 0;i--){
    if(source_range[i]=="COMPLETE"){
      var targetRange = target_sheet.getRange(target_sheet.getLastRow() + 1, 1);
      source_sheet.getRange((i+1), 1, 1, source_sheet.getLastColumn()).moveTo(targetRange);
      source_sheet.deleteRow((i+1));
    }
  } 
}

Here is the link to a copy of said sheet (it is in Dutch).



Read more here: https://stackoverflow.com/questions/66346114/double-the-variables-in-move-script-google

Content Attribution

This content was originally published by Thomas Rooyakkers at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: