'Google Apps Script Trigger time based fires but dont work
I have a spreadsheet in which I control class vacancies and a script that updates a form in which students choose class times. Spaces close 10 minutes before class time. For example: It is 8:30 am and the 9 am class appears on the form. At 8:50 am, the form is updated and the 9 am class no longer appears. The script's logic is: it updates two form drop list based on 2 spreadsheet columns. These columns are updated through formulas and everything is working perfectly! The script has two triggers that fire the same function. One is triggered every minute and the other every time the form is submitted. This is the code!
function AtualizaDados() {
var form = FormApp.openById("1wkNNXr7L4OEm_7txcdlE2Mbpc0ei8JNHf-OGFiVdRuQ");
var namesList = form.getItemById("2124567779").asListItem();
var diaList = form.getItemById("1001915448").asListItem();
var ss = SpreadsheetApp.openById("1u-XGzc52l6PotMFmSwihg2oiLHABO0hbsDWBm4YC_9U");
var names = ss.getSheetByName("Prog Agenda");
var quantidade = names.getRange("O10").getValue();
var quantidadeDia = names.getRange("O12").getValue();
var DeuHora = names.getRange("B22").getValue();
var namesValues = names.getRange(3, 12, quantidade).getValues();
var diasValor = names.getRange(3, 14, quantidadeDia).getValues();
var studentNames = [];
var diasDispo = [];
for (var i = 0; i < namesValues.length; i++) {
if (namesValues[i][0] != "") {
studentNames[i] = namesValues[i][0];
Logger.log(studentNames);
}
}
namesList.setChoiceValues(studentNames);
for (var i = 0; i < diasValor.length; i++) {
if (diasValor[i][0] != "") {
diasDispo[i] = diasValor[i][0];
}
}
diaList.setChoiceValues(diasDispo);
}
Two months ago, it worked fine. Now the form is only updated when someone sends a response. The time trigger fires correctly every minute but it doesn't update the data! (It updates with the same data as the previous minute, even if it's not in the spreadsheet column). The form submission trigger works correctly. can anybody help me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
