Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

341
Visualizações
Apps Script and Google Sheets, Creating calendar event

When I try to run the following code when the start and end dates are the same (to create a calendar event from data submitted through Google Forms), I get this error: Exception: Event start date must be before event end date.

else if (approval == Approval.Approved) {
// If approved, create a calendar event.
CalendarApp.getCalendarById(email)
    .createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        endDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Since employees can request a full or partial day off, I would like the script to be able to run even if the values are the same. How would I make this happen?

Also, for background, I have very limited coding experience (next to nothing except for basic R), so if it's possible, please dumb it down for me. Thank you so much for your time and help!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As per documentation (https://developers.google.com/apps-script/reference/calendar/calendar), you can:

Create a one-day event like so: createAllDayEvent(title, date)

.createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Create multiple-day events like so: createAllDayEvent(title, startDate, endDate)

.createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        endDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Create partial-day events like so: createEvent(title, startTime, endTime, options)

.createEvent(
        'OOO - Out Of Office',
        startTime,
        endTime,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

With regard to times in Apps Script, here's a snippet of syntax:

new Date('July 20, 1969 20:00:00 UTC');

And docs link: https://developers.google.com/google-ads/scripts/docs/features/dates

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda