Global ID error when trying to create an attribute rule when updating a related table.

176
0
02-16-2024 07:09 AM
Labels (1)
FranklinAlexander
Occasional Contributor III

I am trying to create an attribute rule that populates a field in an origin table when a field in a child table is updated. This could be from adding a new record, or updating an existing record. Both tables have a field named "NID", which is being used as the relationships primary and foreign keys. The NID field in the parent table has unique values and the NID field in the child table can have multiple of the same value, so the relationship is many to 1.      

Child table.png  Parent table.png         

 

 

 

 

 

 

                                                                                                                                        

The problem I am running into is when I try and return the results. I have looked at examples and read the Esri documentation, but still find if very confusing. I keep getting an error about Global IDs and not sure why. Both of the tables have GobalIDs, but they are not being used as key fields so I don't understand the error.

GlobalID_error.PNG

 

 

 

 

 

 

 

 

 

Here is my code so far:

 

var parTble = FeatureSetByName($datastore, "ParentTable", ["NID"], false)
var spTble = FeatureSetByName($datastore, "Species_table", ["NID"], false)
var nid = $feature.NID
//var nid = 4
Console("NID = " + Text(nid))
var nidCnt = Count(Filter(spTble, "NID = @nid"))
Console("Count = " + Text(nidCnt))
var relatedRecord = FeatureSetByRelationshipName($feature, "ParentTable_Species_table", ["Species_table"])
Console("Parent table feature count = " + Text(Count(relatedRecord)))
if(Count(relatedRecord) == 0) {
    Console("Adding new record to parent table")
    return null
} 

return {
    //"result": Text(nidCnt) + " records found for NID #" + Text(nid),
    "edit": [{
        "className": "ParentTable",
        "updates": [{
            "NID": "NID",
            "attributes": {relatedRecord: Number(nidCnt)}
        }]
    }]
}

 

 

Also, I know I need to add a new record to the Parent table if a new NID is entered in the child table (ex 7), but I will worry about that when I get this working! 🙂 

Tags (2)
0 Kudos
0 Replies