Auto populate a field from related record using Arcade calculated expressions

360
4
02-13-2024 08:18 AM
cat206
by
Occasional Contributor

Hi, I know it's possible to grab data from the related record (inventory) when adding in a new related table (inspection record) available here: Common calculated expressions for ArcGIS Field Maps (esri.com)

However, I have numerous feature classes (point, line and polygon) with one related table (for all inspection records). Does anyone know if you can use Field Maps Designers Arcade expression to ensure a field from the parent inventory layer (could be either point, line or polygon) can automatically populate the related table record? 

0 Kudos
4 Replies
BlakeTerhune
MVP Regular Contributor

Hopefully I understand your question correctly and I don't have it backwards. I think you can use the FeatureSetByRelationshipName function in Arcade to make a calculated expression on the field in the form. This assumes you have a relationship class created in the geodatabase.

https://youtu.be/TbDY0IpaDoI?si=RXUdEzR5SrS_hrnT

0 Kudos
cat206
by
Occasional Contributor

Thanks for commenting BlakeTerhune - I have tried to do this but i have numerous related layers going into one related table. See below screenshot when i try to use the related features: 

cat206_0-1707915087862.png

So depending which layer the user with click on and add a related record to, I will need the ID field carried across - hopefully that makes a bit more sense?

 

0 Kudos
anbinh
by
Occasional Contributor

Hey Cat,

 

Have you got any progress on this? I am also looking for the same thing as you.

 

Regards,

AB

0 Kudos
cat206
by
Occasional Contributor

Hi,

Unfortunately not no, I tried the FeatureSet but because there are multiple, it fails to calculate

// Get the feature set for the hydrants
var maintenance = FeatureSetById($datastore,'ff83973e1a074d4ab758fce9d88f5339', ['Maintenance_Type'], false)


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

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