Select to view content in your preferred language

Text Field Populated Using Javascript Calculation Works With Default Data But Not Fresh Data

236
4
Thursday
JonMarks
Regular Contributor

The subject probably doesn't make a lot of sense, but I have a text field that uses a calculation involving a few Javascript scripts.

My form calculates whether a species is dominant in a wetland.

Possibly not relevant in finding a solution but thought I'd post this bit anyway, the steps for the test are to apply the 50/20 rule which is: select plant species from the list and rank in descending order of coverage until the cumulative coverage immediately exceeds 50% of the total cover. If two or more species are equal in cover, they should be selected as a group. Then add any other species that comprise at least 20% of the total cover. All these species are considered to be dominant.

In Connect, when I load up some default data, the calculation works as it should, i.e. flagging that the first 3 and the last species are dominant, however if I remove the default data from the XLSX and reload the survey then complete the survey using "fresh" data, the calculation does not update the field.

This snip shows data that has been entered in the default field, I have not altered anything following the form loading.

JonMarks_0-1747370819871.png

If I remove the default values from the XLSX, save it, then load the same values manually, the calculated field  (Dominant Species) does not update.

JonMarks_1-1747370944024.png

Deleting the "calculated" value in the Dominant Species field and refreshing does not correct the response.

I'm using Connect Version 3.22.49, relevant files attached.

Thanks in advance

0 Kudos
4 Replies
Neal-Kittelson
Frequent Contributor

It appears the js script for the insput string list in the findSpeciesInDominantList is triggering immediately upon page load, so without defaults you have a bank list. I couldn't figure out how to get that list to re trigger with updates on your form (not the best at js, maybe someone else can shed some light on that)(also weird cause the others function with updates),  however I have a different solution that doesn't involve a pulldata,  if you use "if(selected(${Species_Ranking_DominantSpeciesIDs},${Herb_1_SpeciesID}),'Yes','No')" I believe you get the same functionality you were looking to get with the js function.

0 Kudos
JonMarks
Regular Contributor

Thanks for spending time on this, I'm very much a beginner with js, and I was trying to find a complicated solution when a simple one sufficed, and works!! Be good to understand why the js doesn't re trigger after update, but in the interim, I have a solution. 

I'll won't mark this post as solved just yet, in case somebody can answer the question, if I hear nothing in a few days, I'll mark this as the accepted solution. 

Thanks again.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Have you tried adding a calculation mode or having a relevant so that it does not fire until the fields are filled out?
https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-calculation-modes/... 

0 Kudos
Neal-Kittelson
Frequent Contributor

I did try making all his JS functions relevant, with no luck, for some reason that list is built at the very beginning and doesn't update.  I did not try the calculation mode because I came to the conclusion it was the JS and not the calculation, however I can't rule out that that wouldn't work. 

0 Kudos