Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
trying to change all new calendar events to busy(opaque) and default calendar view

I have appcript the uses google calendar I was able to easily figure out how to update calendar events to default calendar visibility; however, I am having a tough time making sure all my events are set to busy(opaque) on my calendar on occasion people set an event as free and it causing me trouble with double bookings. I am using google calendar api my function is below. I am a novice. function


  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet1");
  var ssId = ss.getId();
  var sheetId = ss.getActiveSheet().getSheetId();

  var start_time = new Date();
  var end_time =new Date(new Date(start_time.getTime() + 120 * 1000 * 60 * 60 * 24)) ;
  var id_cal = sheet.getRange("C2").getValue();

  var cal = CalendarApp.getCalendarById(id_cal);
    var events = cal.getEvents(new Date(start_time), new Date(end_time));

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

    
    
    var vis = events[i].getVisibility();

    if (vis != CalendarApp.Visibility.DEFAULT) {
var setvis = events[i].setVisibility(CalendarApp.Visibility.DEFAULT); 
var splitid = events[i].getId().split("@")[0];
var freebusy = {transparency: "opaque",
  };
var setbusy = Calendar.Events.patch(freebusy, id_cal,splitid);
var title =  events[i].getTitle();
var data = [title];
var lastupdate = new Date();
  sheet.insertRows(5, 1);
  sheet.getRange(5, 1, 1, 1).setValues([data]);

    }

  


  }


  Logger.log("Events have been added to the Spreadsheet");
  Logger.log("Filter has been added.");
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!