Last active
June 2, 2022 06:58
-
-
Save seoutopico/26dd997effa3b00544ae3d16c0090266 to your computer and use it in GitHub Desktop.
Una función que me permite Agendar eventos en Google Calendar a partir de un listado de tareas. Sheets + app scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addCalendario() { | |
//1- Acceso al calendario | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // acceso al sheet | |
var calendarId = spreadsheet.getRange("B2").getValue(); //celda donde esta el ID | |
var tasktCal = CalendarApp.getCalendarById(calendarId);//le pasamos el ID | |
//2. hacer un array con la informacion a meter | |
var schedule = spreadsheet.getDataRange().getValues(); //donde estan los datos | |
/** | |
* //slice https://www.freecodecamp.org/espanol/news/javascript-splice-como-ulitizar-el-metodo-splice-de-arreglo-en-js/ | |
*/ | |
schedule.splice(0,4); //quito las filas 1, 2, 3, 4, que no las necesito para mi "schedule array arriba declarado" | |
/** | |
* los argumentos son, title, starTime, endTime -> añadimos las columnos que necesitamos para cada arg.empieza en 0 | |
*/ | |
schedule.forEach(function(entry){ | |
tasktCal.createEvent(entry[5],entry[0],entry[1],{ | |
description: entry[4] | |
}); | |
}); | |
} | |
//Menú para lanzar el script | |
function onOpen() { | |
SpreadsheetApp.getUi() | |
.createMenu('⚙ TOOLS') | |
.addItem('Agendar', 'addCalendario') | |
.addToUi(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment