Select to view content in your preferred language

Field Maps and Calculated Expression in field

103
6
Thursday
CJCowardin
Emerging Contributor

I have a field called Park Name in my form and the user selects the park from a list of options.  

I have another field called Parent_Asset_ID.  The asset ID's have already been assigned and each park has a parent asset id.  Instead of the user having to pick this, I would like the field to fill in automatically based on the park name they selected in the previous step.  How can I do this?  Where would I have to put the list of Parent_Asset_ID's? I did all the parks layer to my field maps and the asset id's are in there.  

CJCowardin_0-1736434060496.png

 

0 Kudos
6 Replies
ZachBodenner
MVP Regular Contributor

If there's no relationship class or anything like that to rely on, you could use a Calculated Expression on the Parent_Asset_ID field. Here's an example where I would use the value from a tree species field to populate a "general tree category" field.

 

if($feature.species=='Bur Oak (Quercus macrocarpa)'){ return 'Oak' }
else if ($feature.species=='Ginko (Ginko biloba)'){ return 'Ginko' }
else if ...

 

Then you just match up the appropriate asset id. Possibly a bit ham-handed, but it all depends on your setup. If the user isn't creating a feature, then you can't do an intersect, and if there's no relationship class, you can't call it out that way. 

Happy mapping,
- Zach
0 Kudos
CJCowardin
Emerging Contributor

Thank you. I appreciate the feedback. May be time consuming with 200 parks but if it's the only way.

0 Kudos
ZachBodenner
MVP Regular Contributor

A slightly quicker option might be the Decode function in Arcade. That one works by just using matched pairs. As an example:

var p = $feature.ParkName
var assetID = Decode(p,'Park Name 1','Asset ID 1','Park Name 2','Asset ID 2', etc,'Default Value')

It's a faster type anyway, does the same thing as the multiple If-else lines.

Happy mapping,
- Zach
0 Kudos
DavidPike
MVP Frequent Contributor

Might be best to create a Dictionary to store the Keys and Values, then expression using if else with HasKey() or DefaultValue()

0 Kudos
DuncanHornby
MVP Notable Contributor

Suggest you read this blog, then follow the links to examples, you put the calculate expressions into the layers form.

0 Kudos
KerriRasmussen
Esri Contributor

@CJCowardin Does the park ID need to be filled out when the data is being collected in the field? If not, you can do some post-processing on your data and add those park IDs to the data back in the office. You can either do it manually with a field calculation or set up a python script. 

0 Kudos