Hey everyone, I’m in a pickle with my Google Sheets script. It was working fine for a week, but now it’s acting up. The script is supposed to move rows between sheets based on cell values when a Google Form is submitted. I’ve tried to move it to a different spreadsheet and even messed with the trigger, but no luck.
Here’s a simplified version of what I’m trying to do:
function moveRow(e) {
var sheet = SpreadsheetApp.getActive();
var sourceSheet = sheet.getSheetByName('Responses');
var targetSheet = sheet.getSheetByName('Processed');
var data = e.values;
if (data[2] == 'MOVE') {
var lastRow = sourceSheet.getLastRow();
var range = sourceSheet.getRange(lastRow, 1, 1, sourceSheet.getLastColumn());
var rowValues = range.getValues()[0];
targetSheet.appendRow(rowValues);
sourceSheet.deleteRow(lastRow);
}
}
The execution history shows no errors, but the rows aren’t moving. Any ideas what could be wrong? I’m stumped!
Have you considered the possibility that your form submissions aren’t triggering the script anymore? This can happen if the form’s connection to the sheet gets disrupted. I’d suggest manually running the script to see if it works when executed directly. If it does, the issue likely lies with the trigger.
Another potential problem could be changes in your sheet structure. Ensure that column indexes in your script still correspond to the correct columns in your ‘Responses’ sheet. It’s easy for these to get out of sync if you’ve modified the form or sheet layout.
Lastly, try adding some error handling to your script. Wrapping your code in a try-catch block and logging any errors could provide valuable insights into what’s going wrong behind the scenes.
I had a similar problem before and it was pretty frustrating. In my case, I discovered that the trigger seemed to disconnect without any clear error. I ended up checking the trigger settings to ensure it was still correctly linked to my script. I also verified that the sheet names were a perfect match with those referenced in the code, because even an extra space can cause an issue.
Adding some Logger.log() statements really helped track down where things were going wrong. I eventually switched to an onEdit trigger, which worked more consistently for my setup. I hope this helps you troubleshoot the issue.
hey mate, i’ve run into this before. check if ur form is still linked to the sheet properly. sometimes it gets wonky. also, try adding some console.log() statements to see where it’s breaking. could be something silly like a typo in sheet names or column numbers. good luck!