Working on an attribute rule that populates a M:N relationship table between two polygon layers in cases where they intersect.
In this case the intermediary relationship table is RelationshipTable_AB that includes the project_name field from Project A, project_number (PROJA_NUMBER) field from Project A and intersecting project_number field from Project B, as well as Global ID. For some reason the M:N relationship class in EGDBs in Enterprise 10.9.1 is not updated automatically upon creation/update/deletion of intersecting layers and needs to be attributed to update the intermediary relationship class table manually.
Anytime a Project A or Project B polygon is just updated , it seems to generate a double entry in the relationship table, one with the correct values with all fields populated, and one with NULL values for the project_name and project_number (PROJA_NUMBER) from Projects A that is not correct.
Is there logic or a function in Arcade that checks to see if a record exists in a table before inserting/updating the relationship table?
I can't seem to find a function that does so in documentation.
This is a snippet of my attribute rule applied to Projects_A upon insert and update triggers:
var fs = FeatureSetByName($datastore, "Project_B");
var fsInt = intersects(fs, $feature);
var payload = [];
var c = 0;
for (var proj in fsInt)
{
payload[c++] = {"attributes": { "PROJECT_NAME": $feature.project_name, "PROJA_NUMBER": $feature.proja_project_number, "PROJB_NUMBER": $feature.projb_project_number} }
}
return {
"edit": [{"className": "RelationshipTable_AB",
"adds": payload
}]
}
This is a snippet of my attribute rule applied to Projects_B upon insert and update triggers:
var fs = FeatureSetByName($datastore, "Project_A", ["project_number"]);
var fsInt = intersects(fs, $feature);
var payload = [];
var c = 0;
for (var proj in fsInt)
{
payload[c++] = {"attributes": {"PROJECT_NAME": $feature.projectname, "PROJA_NUMBER": proj.proja_project_number,"PROJB_NUMBER":$feature.projb_project_number}}
}
return {
"edit": [{
"className": "RelationshipTable_AB",
"adds": payload
}]
}