Apps Script createEventFromDescription

createEventFromDescription

Apps Script from a description. Here’s a code snippet that demonstrates how to achieve that:

function createEventFromDescription() {
  var calendarId = 'YOUR_CALENDAR_ID'; // Replace with your calendar ID
  var description = 'Event Description'; // Replace with the description for your event

  var calendar = CalendarApp.getCalendarById(calendarId);
  var event = calendar.createEventFromDescription(description);
  
  Logger.log('Event created: ' + event.getTitle());
}

In the code above, replace 'YOUR_CALENDAR_ID' with the actual ID of your Google Calendar where you want to create the event. Also, update 'Event Description' with the desired description for your event.

The CalendarApp.getCalendarById(calendarId) retrieves the calendar object using the provided ID. Then, createEventFromDescription(description) creates a new event based on the provided description. The event object is returned, and you can perform any further operations or access its properties if needed.

To execute the code, follow these steps:

  1. Open the script editor in your Google Sheets or create a new Google Apps Script project.
  2. Paste the code into the editor.
  3. Save the project.
  4. Run the createEventFromDescription function by clicking the play button or by going to “Run” -> “Run function” -> “createEventFromDescription”.
  5. Check the Logs by going to “View” -> “Logs” or by pressing Ctrl + Enter (Cmd + Enter on a Mac) to see the log output with the created event’s title.

Make sure that you have the necessary permissions to access and modify the specified calendar.

use the createEventFromDescription which is free form if the date values in the sheets is not formatted as a date.  generally if it looks like a date it will set the cell as a date

// Creates a new event and logs its ID.
var event = CalendarApp.getDefaultCalendar()
    .createEventFromDescription('Lunch with Mary, Friday at 1PM');
Logger.log('Event ID: ' + event.getId());