AnsweredAssumed Answered

AddCodedValueToDomain, how to add an empty string value

Question asked by lftgly on Jun 1, 2019
Latest reply on Jun 4, 2019 by lftgly

Here's a code snippet we're using to create a domain, and add values to it, for the purpose of constraining street name prefix directionals:

arcpy.CreateDomain_management(GeodatabaseName, "StreetNameDirectional", "prefix directional of parsed street name", "TEXT", "CODED")
domDict = {"N":"North", "S": "South", "E": "East", "W": "West", "NE": "Northeast", "NW": "Northwest", "SE": "Southeast", "SW": "Southwest"}
for code in domDict:
arcpy.AddCodedValueToDomain_management(GeodatabaseName, "StreetNameDirectional", code, domDict[code])

In ArcMap's Table interface, while editing a row, the 8 values and descriptions appear in the combo-box list for fields that have that domain applied. So far, so good.

However, after a row has a value of "N" in that field, there is no way to change it from "N" back to none, i.e. an empty string, using the combo-box list

I can use the Field Calculator to set it equal to "", an empty string, but that's not an intuitive solution. I want an empty string value with a description of "none".

 

In the ArcCatalog tree, Database Properties, Domain tab, I tried adding a 9th row to the StreetNameDirectional domain with no value, and Description = "None". Click Apply, looks okay, close ArcCatalog, and there's no 9th row of domain values & descriptions. 

 

Adding two double-quotes as the 9th row Value for the domain, with Description = "None", only succeeds in adding a pair of double-quote ASCII characters in the prefix directional field.

 

I want to do this programmatically, using arcpy.AddCodedValueToDomain_management, but I can't even do it through the ArcCatalog user interface. I can't find anything documented RE: including an empty string in a coded value domain. 

 

I should add a related annoyance, that's more trivial: The field is nullable, so "<Null>" appears at the top of the combo-box list.  I don't want the user to choose a null value, I want an empty string value; and ArcMap won't let you select <Null> from the list, throwing an error that "This field will only store string values with up to 2 character(s)". 

Thanks in advance for any assistance you may provide.

Outcomes