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

328
Visualizações
Google Calendar API - getEvents everyday and only certain events with time frames

I am trying to write a script that I can click a custom menu button and it will pull all the events scheduled on my calendar within the hours of (9:00 AM - 11:00 AM , 12:00 PM - 1:00 PM , 3:00 PM to 5:00 PM). Right now it runs by grabbing everything on my calendar for the day (including lunch) and internal meetings but I only need the events that are scheduled within the specific hours.

Also is it possible to only pull certain things from the description of a google event? For ex, the getDescription will get everything included and most of it is not needed, though there is a linkedin profile URL in the description that i do need. How can I set it so it gets the description and only retains the items I want? Here is the script I am running in App Script with the Calendar API.

function getEvents(){

  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var cal = CalendarApp.getCalendarById("ID");
  var today = new Date();
  var dd = today.getDate();
  var mm = today.getMonth(); //January is 0!
  var yyyy = today.getFullYear();
  var hh = 

  var events = cal.getEvents(new Date(yyyy, mm, dd, 0, 0, 0), new Date(yyyy, mm, dd, 23, 0, 0));

  for(var i = 0;i<events.length;i++){

   var title= events[i].getTitle();
   var sd = events[i].getStartTime();
   var loc = events[i].getLocation();
   var des = events[i].getDescription();
   var email = events[i].getGuestList().map(function(x) {return x.getEmail();}).join(',')
  
   ss.getRange(i+2, 2).setValue(title);
   ss.getRange(i+2, 8).setValue(loc);
   ss.getRange(i+2, 9).setValue(des); 
   ss.getRange(i+2, 9).trimWhitespace();
   ss.getRange(i+2, 1).setValue(sd);
   ss.getRange(i+2, 1).setNumberFormat("mm/dd/yyyy");
   ss.getRange(i+2, 7).setValue(email);
  }
 }


function addCandidates()  {

  let ui = SpreadsheetApp.getUi();
  ui.createMenu('Run Code').addItem('Add New Candidates','getEvents').addToUi();



}
about 4 years ago · Juan Pablo Isaza
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