6 years after this is asked, but thankfully so, I had the same issue and tried everyone's options. Like the comments, it sometimes works and sometime doesn't.
So I simply made a if else statement to make sure all entries aren't blank and only then run the code.
function move() {
var source = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('PROCESS');
var source_range = source.getRange(3, 15, 1, 6).getValues();
var target = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('SUBMISSIONS');
var target_range = target.getRange(target.getLastRow() + 1, 2, 1, 6);
var check = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('INPUT');
var check_order = check.getRange(7, 15, 1, 1);
var check_firstname = check.getRange(9, 15, 1, 1);
var check_lastname = check.getRange(11, 15, 1, 1);
var check_email = check.getRange(13, 15, 1, 1);
if (check_order.getValue() === '' ) {
Browser.msgBox('Error','Please make sure all fields are filled.', Browser.Buttons.OK);
} else if ( check_firstname.getValue() === '' ) {
Browser.msgBox('Error','Please make sure all fields are filled.', Browser.Buttons.OK);
} else if ( check_lastname.getValue() === '' ) {
Browser.msgBox('Error','Please make sure all fields are filled.', Browser.Buttons.OK);
} else if ( check_email.getValue() === '' ) {
Browser.msgBox('Error','Please make sure all fields are filled.', Browser.Buttons.OK);
} else {
target_range.setValues(source_range);
var datecell = target_range.offset(0, -1, 1, 1);
datecell.setValue(new Date()).setNumberFormat('YY-MM-DD HH:mm:ss');
var clearsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('INPUT');
clearsheet.getRange("J3:K4").clearContent();
clearsheet.getRange("B8:B25").clearContent();
clearsheet.getRange("H8:H9").clearContent();
clearsheet.getRange("H11").clearContent();
clearsheet.getRange("O7:P16").clearContent();
}
}
Works perfect. Even better, you probably can customize the .msgBox
to reference the error, and another if all good— saying what was submitted.