Reputation: 3
The script is supposed to run when data from a partially completed form is submitted, and fill the incomplete row with data from above.
I have replaced the trigger with onEdit and the code worked perfectly, however when formSubmit runs it doesn't seem to do anything.
function formSubmit()
{
var sheet=SpreadsheetApp.getActiveSheet();
var email_address = Session.getActiveUser().getEmail();
var lastRow=sheet.getLastRow()
var lastColumn=sheet.getLastColumn()
var entries=sheet.getRange(lastRow,1,1,lastColumn)
for(var i=1; i<=lastColumn; i++)
{
var cell=sheet.getRange(lastRow,i).getValues()
if(cell==0)
{
var previousCell=sheet.getRange((lastRow-1),i).getValues()
sheet.getRange(lastRow,i).setValues(previousCell)
}
}
}
Upvotes: 0
Views: 71
Reputation: 64140
In this section:
var cell=sheet.getRange(lastRow,i).getValues()
if(cell==0)
{
cell is an array and should be written like this:
var cell=sheet.getRange(lastRow,i).getValues()
if(cell[0][0]==0)
{
You might want to review the use of getValues() and consider what is returned.
You should debug this code as described by Alan Wells by submitting the form yourself.
Upvotes: 1