Hi Xander,
Hoping that you can help me with an Insert triggering event that deletes records in a matching table. I have a feature class, GasFittings, for which we assign TagIds. Once a tag is assigned to a gas fitting, I would like to delete the matching tag from a master table of available tags. I did try to somewhat follow the example here: https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules/, but I was not able to achieve what I wanted. Here is what I have so far and I am just getting started with Attribute Rules. Ant help is greatly appreciated.
//The attribute rule is added to the TagID table on the Field "TagID", which executes a delete for records in Tag table with matching TagID in GasFit Layer
//Get Gas Fit layer
var gasfeature = $feature.AGLTAGID;
var relate = "$feature.name = '" + $feature.AGLTAGID + "'";
//Get TagID Table
var tagidtable = FeatureSetByName($datastore, "Tags");
var match = Filter(tagidtable, relate)
//if we couldn't find it exit (someone might've deleted it)
if (count(match) == 0) return $feature.name;
//get the feature row (we should only have one )
var matchingFeature = first(match)
return {
//we want to just return the value of field `name` no change require
"result": $feature.name,
//this keyword indicates an edit that need to happen, its an array since we can make many edits
"edit": [
{
//the other class we want to edit
"className" : "Tags",
//the type of edit, in this case we want to delete so we say `deletes`, its an array since we can make many deletes
"deletes" : [
{
//what feature we need to delete?
"name" : matchingFeature.name
}
]
}