How to Insert Event in Google Calendar

So what would the full script be to be able to set the title of the event like I currently have plus set the description?

I really do apologize for being so uninformed on these things.

I tried adding the example you gave to my script but I’m not getting any positive results so far.
I see where to get the event ID from but I’m not getting how to initially set the description in the first place.

1 Like

I’ll try to put an example to show the process and how it works.

1 Like

To insert an event into G Calendar, you should go into the Personalization section.

@overshield

It took me sometime to get free to do this.

For simplicity, I will use a Google sheet directly,
This is what is in the Google sheet. The Event ID will be automatically filled by the script.
image

This is the script that reads the information from the sheet and create the calendar event.

function AddEventToCalendar() {
    const sh = SpreadsheetApp.getActive();
  const cal = CalendarApp.getDefaultCalendar(); // or any other wat to access a calendar
  const ss = sh.getActiveSheet();

  let dateStart = new Date(ss.getRange(2,2).getValue());
  let dateEnd = new Date(ss.getRange(3,2).getValue());
  let desc = ss.getRange(4,2).getValue();

  
  let calEvent = cal.createEvent(desc, dateStart, dateEnd);
 
  ss.getRange(1,2).setValue(calEvent.getId());
}

This is the event after executing the script.
image

Now in the next script, I add a description to the meeting.
image

This is done using this script

function ChangeEventDescription() {
  const sh = SpreadsheetApp.getActive();
  const cal = CalendarApp.getDefaultCalendar();
  const ss = sh.getActiveSheet();
  
  let eventID = ss.getRange(1,2).getValue();
  
  let calEvent = cal.getEventById(eventID);

  let newDesc = ss.getRange(9,2).getValue();
  

  calEvent.setDescription(newDesc);
}

The event ID is taken from the last script which was saved in the Google sheet
image

Hope this makes it clear.

1 Like

Ok thanks, I personally won’t be using Sheets for my project for scheduling users.

So I would use an object to do this right?
And would that cause the script to be any different?

1 Like

If you’re not using a sheet then I guess you would call a web API URL. In this case you need a separate URL for creating the event and another one for updating the description.

You also need to save the event ID somewhere you can retrieve later to effect the changes or to delete the whole event.

1 Like

The url wouldn’t charge each time right?

Just kinda the same way I’m doing it now I think

The event ID I can store easily in the cloud object

1 Like

Yes the same with the added functionality to save the event ID to your cloud storage or return it to Thunkable.

You will then need another script for the change and deeply the script to get the URL for the event change.

1 Like

So what would the script be since I’m not using Sheets?

So I am trying to use the app you built but it is not working. When it says copy and paste it, it won’t let me paste it.