I am using Forms in FieldMaps on AGOL to create my form for field data collection for a tree inventory. I would like for a field worker to be able to select the common name from a combo box drop down and then the corresponding scientific name would be auto-filled in. Conversely the worker would be able to select the scientific name and auto-populate the common name field.
I have not been able to come up with a way, any suggestions would be greatly appreciated.
Thank you.
Solved! Go to Solution.
This can be accomplished via the Decode function in a Calculated Expression.
Here is how I do something similar (common name from scientific name).
return Decode($feature["species_scientific"],"Andropogon glomeratus var. pumilus","Bush Bluestem","Jasminum polyanthum","White Jasmine","Passiflora tarminiana","Banana Poka","Rubus sieboldii","Molucca raspberry")
Here are a couple articles may help:
Configure the form—ArcGIS Field Maps | Documentation
Common Calculated Expressions for ArcGIS Field Maps (esri.com)
This can be accomplished via the Decode function in a Calculated Expression.
Here is how I do something similar (common name from scientific name).
return Decode($feature["species_scientific"],"Andropogon glomeratus var. pumilus","Bush Bluestem","Jasminum polyanthum","White Jasmine","Passiflora tarminiana","Banana Poka","Rubus sieboldii","Molucca raspberry")
Here are a couple articles may help:
Configure the form—ArcGIS Field Maps | Documentation
Common Calculated Expressions for ArcGIS Field Maps (esri.com)
Yesterday I used your example to create an expression. I chose to try to create the expression to pull the scientific name when the common is selected. After playing around with it, it looked like everything was good to go, but I didn't have a chance to actually try it before getting called off to something else. I apparently didn't save it. This morning I entered everything in again and I am getting this error:
"Execution error - Line : 1, 7: Call with wrong number of parameters"
return Decode($feature["commonname"],"American snowbell","Styrax americanum","Arborvitae","Thuja spp.","Black tupelo","Nyssa sylvatica","Black walnut","Juglans nigra","Bottlebrush","Callistemon spp.","Camphor","Cinnamomum camphora")
I shortened my species list for posting, but this is what my expression looks like. As far as I can tell my code matches yours. Any chance you can spot the issue or know what the error is indicating? I apologize, I am a novice at this part.
The decode function needs a 'default' value at the end if none of the expressions are true.
Decode(expression, [compare1, return1, ..., compareN, returnN]?, default?)
Often, we return the original value, but could return any text in this case:
return Decode($feature["commonname"],"American snowbell","Styrax americanum","Arborvitae","Thuja spp.","Black tupelo","Nyssa sylvatica","Black walnut","Juglans nigra","Bottlebrush","Callistemon spp.","Camphor","Cinnamomum camphora",$feature["commonname"])
OR
return Decode($feature["commonname"],"American snowbell","Styrax americanum","Arborvitae","Thuja spp.","Black tupelo","Nyssa sylvatica","Black walnut","Juglans nigra","Bottlebrush","Callistemon spp.","Camphor","Cinnamomum camphora","Text if No Match")
R_
Say Hi to Hank for me 🙂
Thank you the missing default value was the problem. But now I am realizing that this solution isn't exactly what I was looking for. It may be that it is the best I can do for now. Because the calculated field (scientific name in this case) is read only, it doesn't work both ways. I wanted the field worker to be able to choose whichever name they know best, common or scientific, and the other would auto-populate.
Thank you for the help.
R.Shackleford
You don't know me, I am unknowable!
Ah in that case - I would recommend editing the domain (choice list) for one or the other.
For example, for common name field, you likely currently have something like this:
American snowbell | American snowbell |
Instead, have both the common name and scientific name in the description:
American snowbell | American snowbell (Styrax americanum) |
This way the user can type in either the common name or the scientific name to find a specific species.
Clever solution. Thanks! Going to give that a try.