I watched this youtube [1] which is in Hindi. I don’t understand what he says but see what he does and that it works. So I tried to replicate to get the same result: for the Confirmation Page of a Google Form to display the date and time. I actually prefer to get the submission time stamp, but perhaps it doesn’t matter. [1]: https://www.youtube.com/watch?v=oC4Os1N5Tjs
So I wrote this in Apps Script, copying directly from the video (shown at 9:40 of the runtime):
function confirmationPage1() { let form = FormApp.openById("1fbdR0F8zBFyn_oz1P4uSdRUBzEAp3EsfemB44LiDaXE"); let date = Utilities.formatDate(new Date(),Session.getScriptTimeZone(), "yyyy-MM-dd HH:mm:ss"); Logger.log(date) form.setConfirmationMessage() }
This doesn’t work, and it’s not telling me the reason: “other error”. So I tried something else using a method which works for generating an email that includes the time stamp, like this:
function confirmationPage2(e) { var formResponse = e.response; var date = e.response.getTimestamp().toString().substring(0, 24); let form = FormApp.openById("1fbdR0F8zBFyn_oz1P4uSdRUBzEAp3EsfemB44LiDaXE"); Logger.log(date) form.setConfirmationMessage() }
Again, same result – doesn’t work. Any help – greatly appreciated!
Bonus: at the end, I don’t really just want to display the time stamp in the confirmation page, but a link that includes the time stamp (a link to another google form that’s pre-filled with the time stamp of this one, so that I know which respondent continued to the next one. But this should not be difficult, if I manage to get it to display the time stamp in the first place.
Advertisement
Answer
Instead of this:
form.setConfirmationMessage()
Try this:
form.setConfirmationMessage(date)
As for the second script, add a trigger that runs confirmationPage2
, Event Source = From Form
Event type = on form submit
Otherwise time will not change for each submission.