Need help with sorting values

299
8
Jump to solution
07-12-2019 01:38 PM
Highlighted
New Contributor

I am creating forms for a forestry study. We collect the diameters of trees in a plot, among other information. I use the repeat feature for collecting tree data. We sort the trees from largest to smallest to calculate the quadratic mean diameter of the 8 biggest trees. 

I am wondering if it's possible to view/sort the tree entries by largest-smallest diameter, in some sort of table, list, other form, etc besides navigating back to the form submission. Interns may see over 100 trees in a given plot, so navigating the entries by hand to figure out which are largest could be inefficient and tedious in a field setting. 

I'm pretty new to Survey123 so I would appreciate any recommendations. Thanks!

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Frequent Contributor

Hi Jessika McFarland

  I put together an XLSForm to illustrate how this could be done. I added a repeat in the survey to capture the diameter of the trees. The survey also includes a calculation that uses a custom JavaScript function to automatically calculate the RMS of the 8 largest diameters from the repeat.  When a survey includes a custom JS function, you must be logged in in Connect or in the Field App to be able to use it.  I hope it helps.

View solution in original post

8 Replies
Highlighted
MVP Regular Contributor

Jessika, 

To my knowledge, that would be beyond the current ability of Survey123.  Survey123 can perform basic functions such as Max, Min, Average, Sum on the all values in a repeat but currently does not have the ability to select or filter prior to performing these functions. That being said, do you need to perform this in the field?

This could be very easily be post-processed on the collected data once submitted.  Not knowing your current workflow, I cannot offer a specific example but would typically use a custom script running in ArcGIS Desktop or Pro. You could even have a place holder in your survey that a script running on the back end could calculate and update the quadratic mean for the eight largest trees for each survey on a nightly basis.

Reply
0 Kudos
Highlighted
Esri Frequent Contributor

Hi Jessika McFarland

  I put together an XLSForm to illustrate how this could be done. I added a repeat in the survey to capture the diameter of the trees. The survey also includes a calculation that uses a custom JavaScript function to automatically calculate the RMS of the 8 largest diameters from the repeat.  When a survey includes a custom JS function, you must be logged in in Connect or in the Field App to be able to use it.  I hope it helps.

View solution in original post

Highlighted
MVP Regular Contributor

Ismael,

Is there documentation available for using this method and was it just implemented in the newest production release?

Reply
0 Kudos
Highlighted
New Contributor

Thank you so much! 

Unfortunately I also lack JS proficiency, and I have not been able to get this to work in the form.

It reads the message:

Error: Qt.createQmlObject(): failed to create object:
c:/Users/jessikamcfarland/ArcGIS/My Survey Designs/QMD test RMS/extensions:2:1: Script file:///C:/Users/jessikamcfarland/ArcGIS/My Survey Designs/QMD test RMS/extensions/JSFunctions.js unavailable

Any ideas?

Thanks a ton - the JS function will be incredibly helpful, just trying to navigate how to implement it now.

 

Reply
0 Kudos
Highlighted
New Contributor

Thanks again, I was able to figure it out over the weekend!

Reply
0 Kudos
Highlighted
New Contributor

Hi Jessika McFarland

Just wondering what you had to do to solve this error? I am having the same problem

Thanks,

Taylor

Reply
0 Kudos
Highlighted
New Contributor

Hi Taylor,

I basically copied the extensions folder with the JS function into my folder for the survey. I was able to edit the function in Notepad to make slight changes, save as a .JS, and it worked pretty well!

The big thing I noticed is that despite the error message in Survey123 Connect, the form works once its downloaded onto your device. If you are receiving similar error messages, you should try downloading the form to assess its functionality. 

Does that answer your question?

Thanks,

Jessika

Reply
0 Kudos
Highlighted
New Contributor

Hi Jessika,

Thanks for your reply! Yeah I did the same thing. The main solution that I found was that when changes were made to the javascript file (or the extensions folder that it was in) I had to completely close out Survey123 Connect and reopen it (not just refresh the form) for the changes to take effect. That might explain why you were having success after the form was published and downloaded to a device, although I can't be sure.

Thanks again,

Cheers

Taylor