Select to view content in your preferred language

Fetch an attribute from a related record

462
2
04-26-2023 03:41 AM
AntonioPatera
Occasional Contributor

Hello. I am a Survey123 user and I would like to switch to Field Maps. In the article Common calculated expressions for ArcGIS Field Maps - Point 2 - Fetch an attribute from a related record, there is a sample script that should do exactly what I need. Only that the explanation, for me who is not a programmer, is unclear or incomplete. This is the script:
// 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
}

It seems to me that wHydrant is the name of the relationship. Where do I find the name of a relationship between a feature layer and a related table created with Survey123? Thanks for your help.

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

You are close.  Note set geometry to false since you so not need it.

var tbl = FeatureSetByRelationshipName($feature, "Points", ['DesignLong'], false);
return First(tbl).DesignLong

0 Kudos
AntonioPatera
Occasional Contributor

Thank you very much for the suggestion. I will try it next week and keep you informed. 🙏

0 Kudos