arcpy calculatefieldmanagement domain field

1362
11
06-16-2020 09:03 AM
BillChappell
Occasional Contributor II

Hi, using arcpy I'm trying to calculate a field that's using a domain. I'm actually calculating 2 fields, one after the other.

The first one works but the second one doesn't set it's new value. No error messages. If I'm not using python and just field calculate it "USER" puts "User-Derived" in the field. However my script just doesn't.

ArcMap 10.6 with a File GeoDataBase Featureclass

 

Any ideas?

try:
# Execute CalculateField

# this one works well.
arcpy.CalculateField_management(ug, "MEASUREDLENGTH", dist, "PYTHON_9.3")
arcpy.AddMessage("Calc'd MEASUREDLENGTH")

# this one is supposed to end up with "User-Derived" but doesn't do anything
arcpy.CalculateField_management(ug, "LENGTHSOURCE", "USER", "PYTHON_9.3")
arcpy.AddMessage("Calc'd LENGTHSOURCE")

Domain Key/Value:
FM Field Measurement
MS Mapping System
USER User-Derived
WM Windmil
WO Work Order Package

Tags (2)
0 Kudos
11 Replies
JoshuaBixby
MVP Esteemed Contributor

If you plan on learning about cursors and using them more often, I suggest you switch to using the ArcPy Data Access cursors, they perform much faster and are more Pythonic:  UpdateCursor—Data Access module | Documentation 

BillChappell
Occasional Contributor II

Yes, I have used both, this was the first one I saw when I googled it. Since I’m updating less than 2,000 records a time this is still very fast.

Sent from my iPhone

0 Kudos