i’m trying to create a form for 502 users to submit tickets on google forms to show the id of the ticket to the user as a confirmation message and to the team who is going to solve it the id is added correctly to the sheet but to the user it shows the id of the previously submitted form
this is the code i know the problem is in getLastRow() so how to make it work please
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const lastRow = sheet.getLastRow();
const idColumn = 1;
const ticketID = 'T-' + Utilities.formatString('%04d', lastRow);
// const ticketID = lastRow
sheet.getRange(lastRow, idColumn).setValue(ticketID);
Logger.log('New ticket ID: ' + ticketID);
// Update the confirmation message in the form
const form = FormApp.openById('1oxTnzU5NRnzAlNFMmyehSf9vkORLs9vj5-XGGDvfqM0');
const message = 'Thank you! Your ticket number is: ' + ticketID;
form.setConfirmationMessage(message);
}