The documentation lists ID field, but I am not able to access it with field mappings. I get a Key Error when trying ID or IncidentID. Name works fine.
# Construct a field mapping object
field_mappings = closest_facility.fieldMappings(arcpy.nax.ClosestFacilityInputDataType.Incidents)
# Map the field from your input data to the incidents
# class's Incident ID
# field_mappings["IncidentID"].mappedFieldName = "ADDRESS_KEY" # KeyError: 'IncidentID'
field_mappings["ID"].mappedFieldName = "ADDRESS_KEY" # KeyError: 'ID'
# field_mappings["Name"].mappedFieldName = 'ADDRESS_KEY' # works
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-144-2a71c2ff6a31> in <module>
5 # class's Incident ID
6 # field_mappings["IncidentID"].mappedFieldName = "ADDRESS_KEY" # KeyError: 'IncidentID'
----> 7 field_mappings["ID"].mappedFieldName = "ADDRESS_KEY" # KeyError: 'ID'
8 # field_mappings["Name"].mappedFieldName = 'ADDRESS_KEY' # works
KeyError: 'ID'
for f in field_mappings:
print(f)
Name
TargetFacilityCount
CurbApproach
AdditionalTime
AdditionalDistance
AdditionalCost
Cutoff
Bearing
BearingTol
NavLatency
How do you populate the ID?
ArcGIS Pro 2.9.2
Jupyter Notebook in Chrome Browser