Greetings all,
I have a JavaScript script for a survey in survey123, this script takes the maximum value of a field of the survey, but I need this maximum value to be filtered by another field of this survey.
The example is the following, I have a field with the kilometres that the vehicles have done and another field where the license plates are, when I run the script it gives me the maximum value in kilometres but I need that maximum value to be the one of a specific license plate and not the maximum of that field.
This would be the script (it is a small modification of one that is already uploaded on the web):
all help is welcome.
Greetings to all.
######################ESPAÑOL################################
Saludos a todos,
tengo un script de JavaScript para una encuesta en survey123, este script toma el valor máximo de un campo de la encuesta, pero necesitaría que este valor máximo se filtrara por otro campo de esta encuesta.
el ejemplo es el siguiente, tengo un campo con los kilómetros que han hecho los vehículos y otro campo donde están las matriculas, cuando ejecuto el script me da el valor máximo que hay en Kilómetros pero necesito que ese valor máximo sea el de una matricula especifica y no el máximo de ese campo.
este seria el script(es un pequeña modificación de una que ya esta subido en la web):
SCRIPT EN LA PARTE QUE ESTA EN INGLES
toda ayuda es bien recibida.
Saludos a todos.
You redefine your params variable which resets your where clause to "1=1", specifying the where clause first will limit your statistics results to that filter, I think you need:
var params = "/query?where=IdCoche='" + IdCoche + "'&f=json";
params = params + 'outStatistics=[{"statisticType":"MAX","onStatisticField":"' + field + '","outStatisticFieldName":"MAX"}]';
it doesn't work I get error 400
it ends up like this, what has happened is that when you paste the script, those ellipses appear, but if you click on the link, you can see the complete address.
The script works halfway, because it gives me the maximum value in the KmFin column, but what doesn't work is the filtering through the IdCoches field.
Did you end up finding a solution? I'm also looking for a way to do this.
Hi @AnnelieseMyers,
unfortunately I have not found the solution to this case, the alternative I used was the use of the search function, the only problem is that it does not bring the value itself, but it shows it for you to select.
Currently the pulldata(@layer) function has been added, with this new utility you can bring values from the service but I have not been able to test it yet.
Greetings Javier
good
unfortunately I have not found the solution to this case, the alternative I used was the use of the search function, the only problem is that it does not bring the value itself, but it shows it for you to select.
Currently the pulldata(@layer) function has been added, with this new utility you can bring values from the service but I have not been able to test it yet.
Greetings Javier