I am using Goolge Apps Script to run a leads form that (1) gathers signup information, and (2) then shows the user the next page (which is a survey) after the complete the signup
My objective is to redirect the user to that survey page after they submit the form, however it is returning the following after they submit the form [].
I understand there are a few ways to redirect to another link, however I'm not sure which one to use or where to put that information within the body of this script (where does it go?)
`
const sheetName = 'Sheet1'
const scriptProp = PropertiesService.getScriptProperties()
function initialSetup () {
const activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
scriptProp.setProperty('key', activeSpreadsheet.getId())
}
function doPost (e) {
const lock = LockService.getScriptLock()
lock.tryLock(10000)
try {
const doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
const sheet = doc.getSheetByName(sheetName)
const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
const nextRow = sheet.getLastRow() + 1
const newRow = headers.map(function(header) {
return header === 'Date' ? new Date() : e.parameter[header]
})
sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow }))
.setMimeType(ContentService.MimeType.JSON)
}
catch (e) {
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))
.setMimeType(ContentService.MimeType.JSON)
}
finally {
lock.releaseLock()
}
}
`
I tried adding the following line of code to multiple lines in the script, and none of them seem to allow it to process.
window.location.replace("http://www.google.com");
I just want it to redirect instead of showing the result above. Thanks!