BUG

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

Last Published: April 25, 2020

Description

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:

Code:
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.

Cause

This is a known issue.

Workaround

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

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

    Article ID:000009403

    Software:
    • 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