Field.Type method returns different values than the input values for AddField, type parameter

Last Published: April 25, 2020


In a Python geoprocessing script, using the ListFields.Type method to return field type returns different values than are required in the AddField command. For example, when listing the fields of a feature class, fc using the following method:

f = gp.ListFields(fc)
ff = f.Next()
while ff:
field_type = ff.Type
field_len = ff.Length
ff = f.Next()
del f,ff

field_type returns 'String' or 'Integer'. However, the AddField command uses 'TEXT', 'SHORT', and 'LONG' as field types.


This is a known issue.


Use a conditional statement to retrieve the correct input value for the AddField field type parameter:

if (field_type == 'String'):
newField_type = 'TEXT'
elseif (field_type == 'Integer'):
newField_type = 'LONG'
end if

    Article ID:000009403

    • ArcMap 9 x

    Get help from ArcGIS experts

    Contact technical support

    Download the Esri Support App

    Go to download options

    Discover more on this topic