Fetching attributes from related record in Field Maps

11-15-2022 02:56 PM
New Contributor III

I'm still quite new to using arcade expressions. Im building a hydrant flush log form. I want certain fields such as Hydrant ID and address to automatically be filled in from the related layer. I'm using this expression but i'm not fully understanding it. What is it that i need to change?


// 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


0 Kudos
2 Replies
New Contributor II



I've recently used this to pass information between feature services as well to automate data collection efforts.


It looks like you're calling the related features in a weird way.


When you're calling a related feature service or table, you only need to reference the relationship class that was created when you created the relationship between them.


I'm assuming this is a 1:M relationship class with the spatial data being the parent feature and the inspection table being the child feature, correct?


You're expression should look something more like...


var hydrants = featuresetbyrelationshipname($feature, "wHydrant");
var hydrant = first(hydrants);

if (hydrant.facilityid != NULL) {
 return hydrant.facilityid;
} else {
return NULL;


I'm assuming "wHydrant" is the relationship name. If you had the expression builder add the related feature service, then disregard the variable set ups and try altering the conditional statement to check. If there isn't a feature, then the expression will NULL the field, but if there is an ID, it will pass that ID to the target field.

Once you've called the related feature service, you can treat its fields as if they were native fields by referencing the variable and field name instead of $feature.[FieldName], so that will make grabbing fields easier too.

To me, it seems like ['facilityid'] is trying to create an array in two places. If it's not triggering an error in your expression, then it might be not be working as expected because you're could be technically passing an invalid data type into the field.

If it's still not working, there may be something weird with how the relationship was set up.

Hope that helps!

New Contributor III

I apologize im still new to all of this yes i do mean the relationship class. A 1:M relationship class with the spatial data being the parent feature and the inspection table being the child feature. It does help a lot. The wHydrant would be the relationship name so basically i would just replace it with mine that's what i understood from the post as well as the facilityid. I used the expression you commented and i replaced the field names and i got this message after testing it: Execution error - Line : 4, 4: Cannot access property of null object

This is the post i got it from Solved: Re: Add Inspection/Related Record: Bring Value fr... - Esri Community

0 Kudos