AnsweredAssumed Answered

Popup window does not show result of Arcade expression

Question asked by xander_bakker on Aug 10, 2017
Latest reply on Aug 14, 2017 by xander_bakker

I have created a Web Map in ArcGIS Online containing polygons for solid waste collection and each polygon contains information of the days the truck collects in that zone and the time range wherein that happens. I thought it would be nice to create an Arcade expression that would show the next moment the truck passes in each area.


For some reason the result of the expression is not shown in the popup. The expression result appears blank for any selected polygon:

This should probably be caused by some error in the expression, but the weird thing is, that the test in the Arcade window does return a valid result:


I wrote some values to the console and in this case it used a polygon with frequency "WS" (Wednesday and Saturday = Miércoles y Sábado):

So, why do I have a result for the test, but in the popup there is no result for the same polygon and attributes?


Below the setting for the popup window:


And the script I have so far:

// 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);
Console('hoy:' + hoy);
Console('hora:' + hora);


var lst_dias = dias[$feature.FRECUENCIA];
Console('lst_dias:' + lst_dias);

var lst_hora_minmax = horas[Upper($feature.HORARIO)];
Console('lst_hora_minmax:' + lst_hora_minmax);

var test = IndexOf(lst_dias, hoy)
Console('test:' + test);

var resultado = 'Not Set';
if (test != -1) {
    Console('hoy en lista')
    resultado = 'pasó hoy:' + $feature.HORARIO;
    hora_max = lst_hora_minmax[1];
    if (hora < hora_max) {
        resultado = 'viene hoy: ' + $feature.HORARIO;
} else {
    Console('hoy no en lista, buscar próximo día');
    // find next day
    var dia_min = lst_dias[0];
    Console('dia_min:' + dia_min);
    var i = 0;
    for (var a in lst_dias) {
    var dia_max = lst_dias[i-1];
    Console('dia_max:' + dia_max);
    if (hoy < dia_min) {
        Console('hoy < dia_min');
        var dif_days = dia_min - hoy;
        var next_day = DateAdd(Today(), dif_days, 'days');
    } else if (hoy > dia_max) {
        Console('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
        Console('hoy entre min y max');
        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;


It is still not finished, but it should give some result and I would expect that it would give me the same result as during the test in the Arcade expression editor.


Does anyone know what might be wrong with the expression or somewhere else?


CC: Kelly Gerrow

Developer Communities