I am very new to Google Apps Script, but I have previous experience creating Google Forms. I created a Google Form in which the first input is "Date". I want to have the current date pre-filled as soon as the Google Form opens without using pre-filled URLs. Is there a way to use the onOpen trigger to pre-fill this field with the current date?
Please see below for the code I wrote so far (I commented out the last two lines because I kept getting an error message while running this function). Overall, I want to call this function every time the Google Form opens, before the user starts filling out the form.
function inputDate(){
var formattedDate = Utilities.formatDate(new Date(), "PST", "yyyy-MM-dd");
Logger.log(formattedDate);
var form = FormApp.getActiveForm();
var formResponse = form.createResponse();
var items = form.getItems();
var formItem = items[0].asDateItem();
//var response = formItem.createResponse(formattedDate);
//formResponse.withItemResponse(response);
}