I'd like for the scientific name to auto-populate when a field worker selects the common name for a tree inventory (and vice versa).

702
6
Jump to solution
12-19-2022 10:59 AM
Rusty_Shackleford
New Contributor II

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.

Rusty_Shackleford_0-1671476052600.png

 

I have not been able to come up with a way, any suggestions would be greatly appreciated.

 

Thank you.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ClayDonaldsonSWCA
Occasional Contributor II

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)

Logical functions | ArcGIS Arcade | ArcGIS Developers

View solution in original post

6 Replies
ClayDonaldsonSWCA
Occasional Contributor II

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)

Logical functions | ArcGIS Arcade | ArcGIS Developers

Rusty_Shackleford
New Contributor II

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.

0 Kudos
RhettZufelt
MVP Frequent Contributor

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 🙂

Rusty_Shackleford
New Contributor II

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!

0 Kudos
ClayDonaldsonSWCA
Occasional Contributor II

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 snowbellAmerican snowbell

Instead, have both the common name and scientific name in the description:

American snowbellAmerican snowbell (Styrax americanum)

This way the user can type in either the common name or the scientific name to find a specific species.

Rusty_Shackleford
New Contributor II

Clever solution.  Thanks!  Going to give that a try.

0 Kudos