We have a line layer representing stormwater pipes, and a table of related records containing information about individual inspections, cleanings and maintenance. When a worker adds a new event to the related records, I want to trigger an attribute rule to fire on the line layer to update a field with the creation date of the most recent related record.
The attribute rule that I want to trigger on the line layer looks like this:
var all_events = FeatureSetByName($datastore, "STORMWATER.stormwater_events_20250926", ['Create_Date', 'Feature_Name'], false)
var id = $feature.assetid
var events = Filter(OrderBy(all_events, 'Create_Date DESC'), "Feature_Name= @ID")
var recent = First(events)
When(recent != Null, Date(recent.Create_Date), Null)
From a previous thread (Attribute Rules to trigger another feature class t... - Esri Community)
@RobertKrisher writes: It is possible to force attribute rules to fire on other features when a feature is modified using the calculationRequired dictionary keyword.
I am not sure how to implement this advice. So far, I have tried setting an attribute rule on the table of related records to run on insert and update. But it does not work and I am not sure how to debug it. Any tips?
// the "asset id" field e.g. "SWGM-1002" in the related records
var id = $feature.Feature_Name
// Are variable names case sensitive here? Is 'globalid' != 'GLOBALID'?
var out = FeatureSetByName($datastore, "pipe_maintenance", ['globalid', 'assetid'], false)
// The related records include outfall inspections (no pipe reference), so the filter can return Null
var devices = Filter(out, "assetid= @ID")
var device = When(Count(devices) > 0, First(devices), Null)
// Can I conditionally return here?
if (device != Null) {
return {
'calculationRequired': [{
'className': "STORMWATER.pipe_maintenance",
// Can I use the asset id, or only global ids?
'globalIDs': [device] }]
}
}
With this "attribute rule" in place, updates to the layer simply fail.
When a worker adds a new maintenance event, it creates a record with a creation date. I want to update the pipe feature layer associated with the related record when this occurs, so that an attribute field in the pipe feature shows the most recent inspection date.
Thank you for your help,
Erik