I have a sheet named "Credentials" populated with the following data:
And another sheet in the same spreadsheet named "Clients" which is linked to a google form:
My goal here is to show on the confirmation message the data from the "Credentials" sheet which is in the same row as the row that is filled when a form is submitted. E.G: the form data that was stored in row 2 should show "usr a" and "pass a" on the confirmation message
I have this apps script to do so but it always shows the last data from the "Credentials" sheet on the form confirmation message and i can't see why:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheet_clientes = ss.getSheetByName('Clients')
var sheet_demos = ss.getSheetByName('Credentials')
var form = FormApp.openByUrl(ss.getFormUrl())
var demosRange = sheet_demos.getRange('A2:B4')
var demosData = demosRange.getValues()
var lr = sheet_clientes.getLastRow()
var user = demosData[lr][0]
var password = demosData[lr][1]
form.setConfirmationMessage('Congratulations: Your user is:\n' user '\n Your password is:\n' password)
}
CodePudding user response:
Example: