Select to view content in your preferred language

Using Calculated Expressions with Related Records in ArcGIS Field Maps

4133
5
12-16-2022 09:35 AM
Labels (2)
KaitlinFinan
Esri Contributor

Have you ever wanted to automatically populate attribute information into new feature to save time and mitigate mistakes? It's possible with calculated expressions in ArcGIS Field Maps! This video was recorded using ArcGIS Field Maps in August 2022. For more information about common calculated expressions and examples, click here.
For further field data management training, check out Esri's Field Data Collection and Management Using ArcGIS course: https://bit.ly/3EyRgd0

Here is some similar code you can copy and paste:

// Get the feature set for the hydrants
var hydrants = FeatureSetByRelationshipName($feature, 'wHydrant', ['facilityid'], true)

// Get the first hydrant (should only be one)
var hydrant = First(hydrants)

// If there was a hydrant, return the facilityid of it,
// Otherwise, return null
if (!IsEmpty(hydrant)) {
return hydrant['facilityid']
} else {
return null
}

5 Replies
SharonUngerer_DNREC
Occasional Contributor

Can you use the relationship name to pull in related records for items that are published to ArcGIS servers?  I have a map service with feature service enabled published and then I added the feature service to ArcGIS Online organizaiton via URL.  Secured it with stored credentials. And Now I am looking to call upon a point layer in the pop-up for a related table for site visits.  I want to do something similar to what you show here where I pull in the site id.  Only I keep getting and error. 

Test execution error: Compilation error - Line : 1, 45: Identifier not recognised. Verify test data.
 
I have also tried adapting the code for the IIF statement instead of an if else.  No luck.  Wondering if it is a limitation of arcade/fieldmaps. 
0 Kudos
KaitlinFinan
Esri Contributor

Hi Sharon,

You should be able to use the FeatureSetByRelationshipName function with that set-up. Someone mentions a similar scenario in the comments to this post: There may be a different issue going on - do you want to share your code and we can take a look?

0 Kudos
JordanHeiman
New Contributor

This video was super helpful! I am trying to setup a form with this feature but I was also hoping to collect data to another table that is related to the first table. In your example this would be like having a child table from the inlet inspection that can also be filled out. Previously we were using Survey 123 and were able to have a repeated record within a form but we are considering switching to Field Maps. Is this sort of set up possible with Field Maps? 

Also, what is the best resource or training videos for learning about setting up Field Maps?

0 Kudos
KaitlinFinan
Esri Contributor

Hi @JordanHeiman yes - that is possible! I just tested it and provided some screenshots. 1. This is where I clicked on a point and saw the related Parent table. 2. After adding a record to the Parent table, I could also add a record to the child table. Now I can see the parent table is related to the point and the child table. I would read this tech support article first to make sure your data relationships are set up correctly for Field Maps https://support.esri.com/en-us/knowledge-base/how-to-set-up-related-tables-in-arcgis-pro-for-use-in-.... You would need to create a relationship class between the point/line/poly layer and the parent table AND create a relationship class between the parent table and child table.

From there, here are is a great Learning Plan to get started with Field Maps https://learn.arcgis.com/en/paths/try-data-collection/

There are a lot of helpful blogs as well https://www.esri.com/en-us/arcgis/products/arcgis-field-maps/resources

We also offer a 2 day instructor led course that is about Field Data Collection and includes Field Maps https://www.esri.com/training/catalog/5952ca883885672fa2147a4f/field-data-collection-and-management-...

 

Screenshot1.pngScreenshot2.png

Esteban_Leguizamo
Emerging Contributor

I am having an issue with this code because now I am trying to pull a value instead of a text field. I am trying to pull a value from the related record as an input, but I just keep getting  "Test execution error: Cannot read properties of null (reading 'toString'). Verify test data."

0 Kudos