Hey Xander Bakker,
I take no credit for this answer as some others researched and found the answer, but I'm happy to report the solution. There is an issue with the editor that caused the error not to be recognized, when the script was failing. The development team is going to work on this.
The hora_max variable was missing a declaration. Please see the highlighted script below:
// weekdays 0=DO, 1=LU, 2=MA, 3=MI, 4=JU, 5=VI, 6=SA
var dias = {'LJ': [1, 4], 'MV': [2, 5], 'WS': [3, 6], 'LWV': [1, 3, 5], 'MJS': [2, 4, 6], 'LaS': [1, 2, 3, 4, 5, 6]};
var horas = {'3PM A 7PM': [15, 19], '6AM a 10AM': [6, 10], '8AM a 12M.': [8, 12], '9PM a 1AM':[21, 24]};
var ahora = Now();
var hoy = Weekday(ahora);
var hora = Hour(ahora);
var lst_dias = dias[Upper($feature.FRECUENCIA)];
var lst_hora_minmax = horas[Upper($feature.HORARIO)];
var test = IndexOf(lst_dias, hoy)
var resultado = 'Not Set';
if (test != -1) {
Console('hoy en lista')
resultado = 'pasó hoy:' + $feature.HORARIO;
var hora_max = lst_hora_minmax[1];
if (hora < hora_max) {
resultado = 'viene hoy: ' + $feature.HORARIO;
}
} else {
// find next day
var dia_min = lst_dias[0];
var i = 0;
for (var a in lst_dias) {
i++;
}
var dia_max = lst_dias[i-1];
console(i)
if (hoy < dia_min) {
var dif_days = dia_min - hoy;
var next_day = DateAdd(Today(), dif_days, 'days');
} else if (hoy > dia_max) {
var dif_days = dia_min + 7 - hoy;
var next_day = DateAdd(Today(), dif_days, 'days');
} else {
// entre min y max, pilas hay más de un elemento
var dif_days = dia_max - hoy;
var next_day = DateAdd(Today(), dif_days, 'days');
}
var mes = Month(next_day) + 1;
resultado = Day(next_day) + "-" + mes + "-" + Year(next_day) + ' - ' + $feature.HORARIO;
}
return resultado;
Add the declaration, and let us know if it fixed the error.
-Kelly