Select to view content in your preferred language

Problem with JavaScript PullData function and web form

891
2
Jump to solution
06-27-2023 06:33 AM
ColinCampbell1
Regular Contributor

Hi all,

I have a JavaScript script/function that identifies which record within a repeat has the most recent date and returns the 'number' of that repeat.  That number is then used elsewhere to bring back another date value from that repeat record to populate a field in the survey's main table.

In the field app this all works perfectly, but when I view it in the web form version it doesn't.  From what I can see it it returns the number of the repeat as '6' or '9' (depending on the date value) even when there aren't anywhere near that number of records with the repeat.

I know there are limitations with using JavaScript within the web form, so I was wondering:

1) Is this one of the limitations (and if so what actual is the nature of the limitation I'm seeing)?

2) If it isn't one of the limitations, what am I doing wrong?  Is there a solution/better way to do this?

I've attached a version of my .xlsx and the script is as below.  I'm logged in when I'm running this and I'm also a beginner with using JavaScript so may not be understanding things properly.

Any help anyone can offer would be hugely appreciated.

 

/*

* JavaScript functions for Survey123

*/

function indexMax(fieldname){

var maxValue = fieldname[0];

var maxIndex = 0;

for (var i =1; i<fieldname.length; i++){

if (fieldname[i]>maxValue){

maxIndex = i;

maxValue = fieldname[i];

}

}

return maxIndex;

}

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Hi. Sorry to inform: This is a known limitation of the web app. Read this help topic for details.

IsmaelChivite_0-1687925092046.png

 

View solution in original post

2 Replies
IsmaelChivite
Esri Notable Contributor

Hi. Sorry to inform: This is a known limitation of the web app. Read this help topic for details.

IsmaelChivite_0-1687925092046.png

 

ColinCampbell1
Regular Contributor

Ah that's good to know.  Many thanks for replying - and all your hard work on Survey123 - it's much appreciated.

0 Kudos