Arcade Return Alias from a Related Table

280
1
08-24-2023 08:01 AM
Labels (1)
BNix_TPA
New Contributor III

I'm working on a field maps app for inspections.  I have a layer that are features and a related table for the inspections.  I was the item type from the feature to fill a field in the related table called "Inspection Type".  My code works to make this happen, but I want to display the alias instead.  Is this possible.  This is the code that works and will return "flammable_materials_locker".

 

// Get the feature set for the hydrants
var inspections = FeatureSetByRelationshipName($feature, 'SMS_Inspection_inspection', ['item'], true)

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

// If there was a hydrant, return the facilityid of it,
// Otherwise, return null
if (!IsEmpty(inspection)) {
    return inspection['item']
} else {
    return null
    }
0 Kudos
1 Reply
CarmelConnolly
Esri Regular Contributor

Try using the DomainName function: https://developers.arcgis.com/arcade/function-reference/feature_functions/#domainname

Might be somehting like the following but syntax untested: 

// Get the feature set for the hydrants
var inspections = FeatureSetByRelationshipName($feature, 'SMS_Inspection_inspection', ['item'], true)

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

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