This function works fine. When the current sheet is not a Google form response sheet. I am using (Everyminute) Trigger
Image of: Sand data (mainData) sheet to (shareData1) sheet
- I am looking for a, When the user submits the Google form whose status is ( Paid ), the data should go on the second sheet which is (shareData1)
The problem here is that this function will not work anymore when I am using the Google Forms response sheet. And it shows an error. Error Image
in the error image for demotion, I am run this function manually, the same error show in Executions AppScript panel.
function doneCopy() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("mainData");
var values = sheet.getRange(1, 3, sheet.getLastRow(), 1).getValues();
var moveRows = values.reduce(function(ar, e, i) {
if (e[0] == "Paid" ) ar.push(i + 1)
return ar;
}, []);
var targetSheet = ss.getSheetByName("shareData1");
moveRows.forEach(function(e) {
sheet.getRange(e, 1, 1, sheet.getLastColumn()).moveTo(targetSheet.getRange(targetSheet.getLastRow() + 1, 1));
});
moveRows.reverse().forEach(function(e) {sheet.deleteRow(e)});
}