Select to view content in your preferred language

How to query a table stored in AGOL using Arcade in Model Builder?

210
0
03-14-2024 12:01 PM
NoahWasserman
Regular Contributor

I need to populate a field in an AGOL point feature service by grabbing the most recent record from a related table also hosted in AGOL (Sites and InspectionReports).  I can do this in AGOL data view using an Arcade expression but I want to automate it in Model Builder and schedule it in ArcGIS Pro.  Right now I can sort the records in InspectionReports to upend the most recent inspection into Sites using the following Arcade expression in AGOL data view but I'm curious if I can translate this to Calculate Field in Model Builder:

 

var ordered = OrderBy(FeatureSetByRelationshipName($feature, "InspectionReports"), "i_site_date DES")
var site = $feature.DBID
var related = Filter(ordered, "DBID = @site")
var relatedfeatures = Filter(related,"Report_type LIKE '%Inspection'")
var last = First(relatedfeatures)

var result;
if(last == null) {
result = Text("")
} else {
result = last.i_site_date
}
return result

 

Can I reference an AGOL table as I did with FeatureSetByRelationshipName($feature, "InspectionReports"), "i_site_date DES") in a Calculate Field Arcade script?

0 Kudos
0 Replies