dynamic code list on plot level (dependent on single tree species)

  • Asked
  • Active
  • Viewed 4332 times
1
1

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...

1

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) (where species is 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 when field write: parent()/count_distinct_species >= idm:position($context)
  • in the Expression field 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?

Fehrmann Fehrmann

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.

Stefano (OF) Stefano (OF) ♦♦
1

Accepted answer

Dear Open Foris Team,

what a beautiful solution! It's working fine and does exactly what I need. Thank you so much!

Your answer

Markdown text. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+E code, Ctrl+Shift+V paste as plain text. Tab indents list items and code; press Escape, then Tab, to leave the text box.

Insert an image

Say what the image shows, for people who can't see it.

Keyboard shortcuts

Anywhere

?
Show this list
/
Search
g h
Go to the home page
g q
Go to the questions
g t
Go to the tags
g u
Go to the users
a
Ask a question

Lists of questions

j k
Next or previous question
Enter
Open the question

Question pages

j k
Next or previous post

Shortcuts never apply while you type in a text field. Members can turn them off in their preferences.