1. What is the issue? Please be detailed.
I have a list of plots, each plot contains a different number of trees with past data associated with it (for each tree we recorded its number, diameter, distance... - see attached file trees.csv).
Now we need to revisit each plot and remeasure some of the parameters for each tree. The work process is as follows: you visit a plot, select its number and then hopefully get a list of trees to (re)measure. I am pretty sure I could work out how to pull data for each tree, but I am stuck on forming an indexed-repeat with a list of all trees in a plot.
Since I have a lot of data and to make it easier to repeat the process next year, I have opted for using external csv files. I managed to get the list of possible plots and also a list of trees in each plot using the select and choices from external file. Instead of selecting tree by tree in a repeat, I think it would be easier to keep track of which trees were already measured on the plot (in some plots there are 200+ trees) by using an indexed-repeat and treat each tree as a pre-set repeat.
However, I keep getting stuck with obtaining the count of trees in each plot to pre-set the number of possible repeats. As a side question, could I name/preset all repeats in advance, so that users could have a list of trees to click on for easier navigation?
Also, is there another (or better) way of doing this?
2. What steps can we take to reproduce this issue?
See attached files.
3. What have you tried to fix the issue?
I have read all possible topics on this and other forums and have been trying to get it to work for the last week with no luck.
4. Upload any forms or screenshots you can share publicly below.
An abbreviated version of the external csv file and form attached.
Hi @luka, I'm no repeat expert, and also get quite confused with repeat logic, especially when they nest! I have previously created a form with a very large CSV that has areas, assets, asset items, item elements, so once the asset is selected a dynamic repeat is created for the number of items, and when the item is selected another repeat is created for the number of elements. Then as they are completed, the elements, and eventually items, are removed from the selections so all must be completed (in any order) with no duplicates.
For your form, I have split the csv (but you can keep a single file if you add another identifying column (eg 'type' with values like 'species' 'plotID' 'tree') and add that to the choice filters) to break out the plot and species selections.
After selecting a plot, the trees within are counted, the repeat count is set to this, then inside the repeat you can select the tree, which will lookup the previous details, show them, and preload the values (except timestamp) to the entry fields (updated if tree is changed). This does not work in Enketo (the repeat count is locked at 1, my other form does set the count correctly...?) but does work in Collect.
It does need some more validation to allow for changing plot (to reset the calculated tree values etc), butI think this solves a lot of your needs?
Hi @ahblake, your solution is almost exactly what I needed, so many thanks for your time and effort. I couldn't get it working at all and now you have renewed my enthusiasm for working on this particular form. I was almost at the point of using paper forms again!
I got everything working, but I am running into some performance issues when having a large number of repeats (trees) in a plot. After selecting a plot with a lot of trees, there is a significant lag when inputting text/numbers or especially when navigating across tree repeats in the form - but only inside the repeat. The app even crashed once or twice on Galaxy Tab Active3, while the lag is less pronounced (but still present) on a newer device (Fairphone 4).
Is there a way to improve the overall performance by changing the form design somehow? I assumed this is related to the number of repeats. I have tried setting the calculations (which pull data from csv) to a fixed number (e.g. 1) to see if performance improved and nothing. I have also removed all calculations from the form, and the lag was still present.
A sample trees.csv and plots.csv, with an added plot no. 5 with over 300 items attached.