'Pre-fill date item

I have been trying to find the right method to pre-fill the start date field in my Google Forms with the current date and time, but I failed to achieve this.

I think the createResponse(hour, minute) would be the best method, however I have absolutely no idea on where to include it in my script:

    function book1() {
var form = FormApp.getActiveForm();
var responses = form.getResponses();
var len = responses.length;
var last = len - 1;
var items = responses[last].getItemResponses();
////// var current= items[2].createResponse(10, 00);
var email = responses[last].getRespondentEmail();
var equipment = items[1].getResponse();
var datestart = items[2].getResponse();
var dateend = items[3].getResponse();
var cal = CalendarApp.getCalendarsByName(equipment)[0];
Logger.log('current '+current);
Logger.log(datestart);
Logger.log(dateend);
var start = new Date(datestart);
var end = new Date(dateend);
Logger.log('start '+start);
Logger.log('end '+end);

var allEvents = CalendarApp.getCalendarsByName(equipment)[0].getEvents(start, end);//Returns an array of events

if (allEvents.length < 1) {

var event = cal.createEvent(equipment, start, end)
.addGuest(email);

MailApp.sendEmail({
    to: email,
    subject: "Equipment " +equipment+ " booking confirmed",
    htmlBody: "Equipment " +equipment+ " available, please return it by " +dateend+ " and scan the QR code when returning it.",
  });

}

else {
  var blob = HtmlService.createHtmlOutputFromFile("calendariframe").getBlob();
  MailApp.sendEmail({
    to: email,
    subject: "Equipment  " +equipment+ " not available",
    htmlBody: blob.getDataAsString(),
  });
};
}

In my latest attempt, I encountered that error;TypeError: items[2].createResponse is not a function

Would you know how to make it work?

Knowing that pre-filling the date and time only simplifies the process of the form users, but that in some cases they will not use the current date and time as a starting time for booking.

Thanks a lot in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source