1
votes

I have a sheet which needs two ways to append records(rows). One is the associated Form and another is the associated script. The script performs successfull .appendRow() and .getLastRow() was incremented, but the next Form submittion appends data after the wrong row which was the privoius last row (.getLastRow-1). I also noticed .appendRow() does not inclease the number shown after Form in the spreadsheet menu like Form(123). It seems like the spreadsheet has two different Last Rows.

Is anyone help me to increase The form Last Rows in a script.

Thanks

1

1 Answers

3
votes

This appears to be an issue with data populated by a script not being automatically absorbed into the so-called Table associated with Form submissions, which is defined by the light grey background. Subsequent Form submissions will be added to the bottom of the grey area (regardless of data underneath), and the Form submission count will only address the rows in the grey area.

A clumsy workaround is to use the copyTo method to copy the data in place, after appending the row:

sheet.getRange(sheet.getLastRow(),1,1,sheet.getLastColumn())
     .copyTo(sheet.getRange(sheet.getLastRow(),1,1,sheet.getLastColumn()));

HTH

Adam