AnsweredAssumed Answered

Attribute Rule Delete Trigger to Update Another Feature

Question asked by Michael.Brown31@jacobs.com_Jacobs on Dec 11, 2019
Latest reply on Aug 21, 2020 by Michael.Brown31@jacobs.com_Jacobs



I've been really enjoying attribute rules and trying them out on a few workflows, mostly with success.  One workflow I have though is not yielding the results I would want/expect.


I have two polygon feature classes, Campus and a Site, that each have an Insert/Update set of triggers that will pass the Campus ID value to the Site feature if they intersect.  If a new Site is created or updated (moved) within a Campus, it will get that Campus's ID value.  If a Campus is created or updated (moved) to intersect an existing Site feature, the Campus ID will be set on that Site feature.


I have a Delete trigger on the Campus whose intent is to set the Campus ID to Null for all Site's that have that deleted record's Campus ID.  While I think the logic for this could be better (it would be great to somehow take the Delete trigger from Campus and then trigger the Site feature to check for intersects again...can you do this?), it seems like it should work.  What I am finding is the Arcade Expression has an Edit/Update to the Site feature to change the Campus ID field value to Null and that in turn is triggering the trigger I noted above where the Site get's the intersecting Campus's, Campus ID value and this never gets set to Null.  It seems the actual delete of the record is happening after the Edit/Update and the Update trigger that runs on Site, so there is still a valid intersect with the Campus record I am deleting.


Here is the Delete trigger on Campus

var fsSitesFilter = filter(fsSites , "Campus_ID = @campusId")
if (count(fsSitesFilter ) == 0) return $feature.ID;


var updates = []

var i = 0
for (var site in fsSitesFilter) {
   updates[i++] = {
      'globalid': site.GlobalID,
      'attributes': {"Campus_ID": null}

return {
   'result': null,
   'edit': [
      {'className': 'sde_blah.Site',
      'updates': updates


Here is the Insert/Update trigger on Site

var fsCampus = FeatureSetByName($datastore, "sde_blah.Campus", ["ID"], true)
var fsSite = Intersects(fsCampus, Geometry($feature))
var campus = First (fsSite)


var campus_id = ""
if (campus == null)
   return null
   campus_id = campus.ID

return campus_id;