Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefill current date in Google Form with Google Apps Script

I have a Google Form to a spreadsheet and I need a date field pre-filled with the current date.

Something like an "onOpen trigger", which updates the date field or a date field with now().

Is this possible in Google Apps Script?

like image 979
Steve_12345 Avatar asked Aug 09 '16 19:08

Steve_12345


People also ask

Can Google Forms auto populate?

You can let Chrome fill out forms automatically with saved info, like your addresses or payment info.


1 Answers

In your case, some of the points of using the Form remain unclear. Suppose that you have the ability to edit a link to the Form or your users agree to add the bookmarklet to their browser.

Common code

let id='1FAIpQLScx-1H1moCzBfkTEOZnVgBScbJeHZ4YE5E6IY2mNZvMuVcOXA';
window.open(
  `https://docs.google.com/forms/d/e/${id}/viewform?usp=pp_url&entry.1000000=`+
  (new Date()).toISOString().split('T')[0]
);

Bookmarklet

Just add the next string to the bookmarks bar

javascript:let id = '1FAIpQLScx-1H1moCzBfkTEOZnVgBScbJeHZ4YE5E6IY2mNZvMuVcOXA'; window.open(`https://docs.google.com/forms/d/e/${id}/viewform?usp=pp_url&entry.1000000=` + (new Date()).toISOString().split('T')[0]);
like image 181
contributorpw Avatar answered Sep 22 '22 13:09

contributorpw