Select to view content in your preferred language

Populate field based on values in other fields collected in Field Maps

1251
6
01-24-2023 03:52 PM
CourtneyWatson
Emerging Contributor

I have a tree dataset that is shared as a service, added to a Map on AGOL with a related table and edited in field maps with some inspection fields:  

  • LikelihoodOfFailure
  • LikelihoodOfImpactTarget

I have a third field called LikelihoodRating that I want to be populated based on the input values of LikelihoodOfFailure and LikelihoodOfImpactTarget on the fly.

So far I have found examples where this can be populated using a calculator with Arcade but I an really hoping this can be done automatically as the field user enters the values in field maps.

The logic I think I am looking for is:

 

if ($feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Very Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Low" {return "Somwhat likely"}
if ($feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Medium" {return "Likely"}
if ($feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "High" {return "Very likely"}

if ($feature.LikelihoodOfFailure == "Probable" && $feature.LikelihoodOfImpactTarget == "Very Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Probable" && $feature.LikelihoodOfImpactTarget == "Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Probable" && $feature.LikelihoodOfImpactTarget == "Medium" {return "Somewhat likely"}
if ($feature.LikelihoodOfFailure == "Probable" && $feature.LikelihoodOfImpactTarget == "High" {return "Likely"}

if ($feature.LikelihoodOfFailure == "Possible" && $feature.LikelihoodOfImpactTarget == "Very Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Possible" && $feature.LikelihoodOfImpactTarget == "Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Possible" && $feature.LikelihoodOfImpactTarget == "Medium" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Possible" && $feature.LikelihoodOfImpactTarget == "High" {return "Somewhat likely"}

if ($feature.LikelihoodOfFailure == "Improbable" && $feature.LikelihoodOfImpactTarget == "Very Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Improbable" && $feature.LikelihoodOfImpactTarget == "Low" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Improbable" && $feature.LikelihoodOfImpactTarget == "Medium" {return "Unlikely"}
if ($feature.LikelihoodOfFailure == "Improbable" && $feature.LikelihoodOfImpactTarget == "High" {return "Unlikely"}

 

 

But i'm not convinced this is possible.  Or will this all need to be done manually post capture?

Can a field be populated at the database level based on fields captured in Field Maps?

 

0 Kudos
6 Replies
SarahSaint-Ruth
Esri Contributor

Hi Courtney,

This is possible and there are a few ways to achieve it. I’ll give you my favorite as I think it’s the cleanest to read (personal preference).

When($feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Very Low", "Unlikely",

$feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Low", "Somwhat likely",

$feature.LikelihoodOfFailure == "Imminent" && $feature.LikelihoodOfImpactTarget == "Medium", "Likely", add in the rest of your statements following the same format,

you need to add a default value”)

The format of the When function is When(expression1, result1, expression2, result2, defaultValue)

Other options include using the IIF function or an If statement.

Hope this helps!

CourtneyWatson
Emerging Contributor

Thank you Sarah, when statement sounds good but I cannot use default values.  Where exactly do I put it though so the field auto populates?

0 Kudos
SarahSaint-Ruth
Esri Contributor

Where to add this in Field Maps

You will need to configure this in Field Maps Designer (Field Maps web application) or in the Map Viewer. You can add expressions as part of configuring the form. Here is the doc on how to configure the Form in Field Maps.  This is the specific part of the documentation that discusses adding Arcade.

Default Values

You just need to add a default value to the end of the expression as that's what is required for the When function. If its a string field you're populating you can use "Undefined". It will only appear as undefined if the conditions you have set in the When() expression are not met.

0 Kudos
CourtneyWatson
Emerging Contributor

Thanks for your help Sarah.  When I open Map Viewer Beta or Classic I have no option to configure the form.

In the Form Builder in the Field Maps app there is also no option to add an expression other than for conditional visibility. Dang.

0 Kudos
SarahSaint-Ruth
Esri Contributor

Hey Courtney is this a hosted feature service and are you using ArcGIS Online?

0 Kudos
CourtneyWatson
Emerging Contributor

It's a shared feature service and i'm using Enterprise 10.9.  That is probably the issue as I need to be on 11.

0 Kudos