Survey 123 CSV Content in custom Javascript

83
0
11-30-2021 08:45 AM
XavierRouxRacine1
New Contributor

Hi everyone,

 

I have an issue with Survey123 about reading a Csv File in a custom javascript function. I would like to pass the CSV data content as an argument to a custom javascript function and get the sum for a field based on the value of 3 to 5 associated records. Here is the javascript function that I want to implement with arg1 as the content of my csv file.

 

 

function myfunction(arg1, arg2, arg3, arg4, arg5) {

 

// Add your code here

var superficie = []

for(var i = 0; i < arg1.length; i++) {

 

if(arg1[i].param1 == arg2) {

if(arg1[i].param2 >= arg3 & arg1[i].param4 <= arg4) {

 

superficie.push(arg1[i].param5)

 

}

 

}

 

}

var total_sup = 0;

for(var i = 0; i < superficie.length; i++) {

total_sup = total_sup + superficie[i]

}

return total_sup;

}

 

 

Thank you

0 Kudos
0 Replies