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

147
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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