Dear all, Special case: I like to collect general information on the status of tree species I found on a plot. Imagine, I have species x, y and z in my tree table and like to add general information on e.g. health (but not for every single tree, rather per species on plot level). Therefore I like to add a table on the plot level. The choice of species in this table should be limited to those I found on the plot (in the tree table). I would need a "dynamic" code list, where I can select from all species that were found on this specific plot (in my case the information is even needed per layer and species). I hope this question is understandable...
Accepted answer
Dear Lutz,
We don't support such a dynamic table nowadays... but... you can try to solve this issue with a workaround using the default values.
First of all, please update Collect to the latest version (3.20.18) and follow these steps:
- define a calculated numeric (integer) attribute at the same level of the tree entity to calculate the number of distinct tree species and call it for example
distinct_species_count - in the calculated value expression write this:
idm:count-distinct(tree/species)(wherespeciesis the name of your Taxon attribute) - define a multiple entity at the plot level
- define a key attribute of type Taxon inside the new multiple entity
- in the default value box, add a new default value
- in the
Apply whenfield write:parent()/count_distinct_species >= idm:position($context) - in the
Expressionfield write:idm:distinct-values(parent()/tree/species)[idm:position($context)] - in the Checks (Validation Rules) box, define a new Custom check to ensure that the inserted species is among the ones defined for the trees
- write this in the
Expression:count(parent()/tree[species=$this]) > 0 - write a custom error message that indicates: Species has not been specified for any tree
Now, when you have already defined a list of trees, whenever you add a new row inside the newly defined entity, the value of the Species field will be automatically populated with the species defined in the tree table.
Please try this solution and let us know if it fits your needs.
Many thanks,
Open Foris Team
A follow up question: how to deal with empty fields? For some trees species is not entered (e.g. dead trees), but the idm:position($context) is not considering this. It works fine in Collect Mobile, but when I open the plot in Collect, my table is shifted and rows are mixed. Is there a way to avoid later re-calculation of fields when I open them in Collect?
Hi Lutz,
The default value applied is not re-calculated when you re-open a record, it's used only to assign a value the first time you create an "entity".
You can try to filter the trees with a specified value for species. The expressions will be:
- idm:count-distinct(tree[not(idm:blank(species))]/species)
- idm:distinct-values(parent()/tree[not(idm:blank(species))]/species)[idm:position($context)]
By the way, in the next version of Collect we will include only not empty values in the distinct-values function... but try to see if these expressions will solve your problem.