Reputation: 15
How can I save data from a form only up to line 15? (as in the picture)?
function addNovaLinha(dadosLinha) {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("resultados");
const dataAtual = new Date();
var limite = ss.getLastRow();
ws.appendRow([dadosLinha.item, dadosLinha.qtd, dataAtual]);
return true;
}
Upvotes: 0
Views: 63
Reputation: 15
thankful for help. I managed to solve. with the response from
Upvotes: 0
Reputation: 11184
You need to add a condition that checks if the last row has already reached 15
.
function addNovaLinha(dadosLinha) {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("resultados");
const dataAtual = new Date();
var limite = ss.getLastRow();
// append row and return true ONLY IF last row is less than 15
if(limite < 15) {
ws.appendRow([dadosLinha.item, dadosLinha.qtd, dataAtual]);
return true;
}
}
Upvotes: 1