I am fairly new to Google script. My knowledge of Java is limited as well (I believe the two are similar). I have a script that moves rows when a checkbox is checked. It also adds some rows and does some other things, please see below for the script. No issues with the script as it is now. What I would like to do is to modify the script so that it stops moving rows when they are checked ( I know how to do that) and to instead move all of the checked rows as a time event. I know I need to add a time trigger and know how to do that however what I do not know is how to tell the script to check what rows are checked. So, basically I would like the script to move all of the checked rows to another sheet, for example at 7 am, and also to add new rows. The number of added rows should be equal to the number of moved rows. If I could get any examples, tips or directions, it would be greatly appreciated.
The script I am using now (found and modified from scripts available online):
​function MoveOnCompleted(event) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ToDo");
var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ToDo");
var data = "B3:B"
var datarange = s.getRange(data);
var r = datarange
if(s.getName() == "ToDo" && r.getColumn() == 2 && r.getValues() == 1) {
var TimeStamp = r.offset(0,1);
var DateTime = new Date();
TimeStamp.setValue(DateTime);
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Completed");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
s.deleteRow(row);
s.insertRowAfter(2300);
var tableRange = "A3:G";
var range = s.getRange(tableRange);
range.sort([{column: 5, ascending: true}]);
}
}
Best Answer
Your data on sheet "ToDo" includes a checkbox in Column B. If the checkbox is checked, then you want to copy that data to the next row on sheet "Completed", and then delete the relevant row from "ToDo".
This solution is in two parts:
true
value on the checkbox (true = checked)