Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Is there a way to check if a next event includes a term in the title?

I have made a script that updates events title after an user submits a form, based on this condition:

for(var j=0; j<events.length;j++){
        var ev = events[j];
        if(!ev.getTitle().includes("Returned"){ ...

I want the script to check if there is one or many events that include the term "Returned", but only among the next events.

For example, the condition should be false if an event title does not include "Returned" AND none of the next events titles include "Returned".

Is that possible? I tried with creating a variable evnext = events[j+1] but of course I get an error once it gets to the last event.

Thank you for your help, I feel it is very doable but my understanding of loops is sadly too low ...

Edit: details on my goal

Actually my script sends an email to all people who borrowed an equipment but did not confirm they returned it.

The problem now is that I would like to send an email to these people EXCEPT IF someone else returned it afterwards.

It would indeed mean that even the first borrower did not confirm he returned it, the fact that someone who took it next and marked it as returns proves that the first person actually returned the equipment.

Otherwise it would not have been possible for the next guy to return it.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can try the following script:

function listEvents()
{
  let calendar = CalendarApp.getCalendarById("Calendar ID"); // Change the calendar ID
  var today = new Date();
  for(let i=1; i<=30; i++) // 30 days limit
  {
    var events = calendar.getEventsForDay(today, {search: 'Returned'});
    if(events.length != 0)
    {
      MailApp.sendEmail("email@domain.com","Subject","Body");
    }
    today.setDate(today.getDate() + 1);
  }
}

In this example the script takes the current date and starts checking day by day of a specific calendar for the upcoming 30 days if an event has the word "Returned" on its title and returns False if not.

Let me know if this helps. I can also modify the script if needed. You can modify the 30 days limit, and the initial date depending on your needs. Do not forget to change the calendar ID to the one you are currently using to save the events.

References:

  • getEventsForDay(date, options)
about 4 years ago · Juan Pablo Isaza Denunciar

0

How about this:

for(var j=0; j<events.length;j++){
        var ev = events[j];
        if(j < events.length - 1) {
          if(ev.getTitle().include("Returned") && events[j+1].include("Returned")) {}
        } else {
          if(!ev.getTitle().includes("Returned") {}
        }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda