I am using Field Maps to collect building inspection records to a standalone table by tapping on a feature in a related building layer. (See Inspect—Add a related report.) The inspection table and building feature class are both stored in an enterprise geodatabase. I have created calculation attribute rules in ArcGIS Pro to automatically copy certain attributes to an inspection record from its related building feature when the inspection is collected.
This process works when collecting inspections through an offline map area in Field Maps: once the edits are synced, the desired attributes automatically get copied over. However, when collecting in Field Maps through an online map, the attributes do not get copied over.
Here is an example of the kind of script expression I am using for my attribute rules. In this case, the rule copies the Town attribute from the related building to an inspection record.
// Don't change anything unless a `Building_ID` was added or modified
if ($originalFeature.Building_ID == $feature.Building_ID) return $feature.Town;
var relatedBuilding = FeatureSetByRelationshipName(
$feature,
"MyEnterpriseGDB.User.Building_Inspection_RelClass",
["Town"],
false
);
// Don't change anything if a related building was not found
if (Count(relatedBuilding) == 0) {
return $feature.Town;
}
return First(relatedBuilding).Town;
The attribute rule is created as follows, where script_expression is the above block.
arcpy.management.AddAttributeRule(
in_table=inspection_table,
name="CopyBuildingTown",
type="CALCULATION",
script_expression=script_expression,
triggering_events=["INSERT", "UPDATE"],
field="Town",
exclude_from_client_evaluation="EXCLUDE",
)
Software versions:
- ArcGIS Pro 2.9.0
- ArcGIS Enterprise 10.8.1
Any suggestions or ideas as to what the problem might be would be appreciated!