1

According to the help file, the ALTER FIELD command is available at any license level.

ArcGIS for Desktop Basic: Yes

Why am I getting a license error when trying to rename a field alias on a sample file geodatabase featureclass?

> arcpy.Describe(u"e:/test.gdb/testFC").fields[2].name
> u'oldfieldname'

> arcpy.AlterField_management(u"e:/test.gdb/testFC", "oldfieldname", "newfieldname"  ,"newaliasname")

> ExecuteError: Failed to execute. Parameters are not valid.
> ERROR 000824: The tool is not licensed.

This is a brand new, standard, empty featureclass which I just created for the purposes of this test.

Stephen Lead
  • 21,119
  • 17
  • 113
  • 240
  • 1
    'TEXT' is not a valid field name? What is your feature class type? Perhaps you'll have better results not using a SQL reserved keyword like "TEXT_Val" see http://gis.stackexchange.com/questions/123736/what-causes-error-000210-cannot-create-output-in-memory-and-from-arcpy/123747#123747. According to http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000198000000 the parameters go feature class, existing field, new name, new alias.. there's nothing there about the type. – Michael Stimson Jun 25 '15 at 00:51
  • Michael is right. Simply change "TEXT" to "newfieldname". – Farid Cheraghi Jun 25 '15 at 00:57
  • You referred to the Add FieldManagement doc – Vince Jun 25 '15 at 00:58
  • @MichaelMiles-Stimson I removed that to avoid confusion - it still fails with the same error message if I give a new field name. In fact I only want to change the alias but that's a separate question.... – Stephen Lead Jun 25 '15 at 00:59
  • 1
    @StephenLead Alter fields is relatively new (10.2.2 I think) - what version are you using? Whichever it is would not explain the error message but might help shine some light. – PolyGeo Jun 25 '15 at 01:04
  • What about arcpy.AlterField_management(u"e:/test.gdb/testFC", "oldfieldname", new_field_alias="newaliasname")... I suspect though that it will have the same problem. Does the feature class support changing fields? I'm fairly sure you can't change a field in a shapefile but you can in pGDB (using Access) provided it's not indexed or 'special', I'm not sure about file geodatabase.. though field alias should be read/write. There's a related post http://gis.stackexchange.com/questions/255/how-to-change-feature-class-and-field-aliases-in-bulk in arcobjects for changing alias. – Michael Stimson Jun 25 '15 at 01:07
  • Will it work from the script, not Python window? – FelixIP Jun 25 '15 at 01:44
  • The field is not a string, drop the quotes around the old field name? – GISI Jun 25 '15 at 02:34

1 Answers1

2

I have no idea why you would receive that error but to move forward I would try running the test code below (with values from your own feature class) from IDLE (or your own IDE).

It worked for me using ArcGIS 10.3.1 for Desktop.

import arcpy

oldFieldName = arcpy.Describe("C:/temp/test.gdb/testFC").fields[4].name
oldFieldAlias = arcpy.Describe("C:/temp/test.gdb/testFC").fields[4].aliasName

print oldFieldName
print oldFieldAlias

arcpy.AlterField_management("C:/temp/test.gdb/testFC", oldFieldName, "NewField"  ,"NewAlias")

newFieldName = arcpy.Describe("C:/temp/test.gdb/testFC").fields[4].name
newFieldAlias = arcpy.Describe("C:/temp/test.gdb/testFC").fields[4].aliasName

print newFieldName
print newFieldAlias

Output was:

>>> ================================ RESTART ================================
>>> 
OldField
OldAlias
NewField
NewAlias
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • Yep, that's pretty much was I was doing (unsuccessfully) in the original test. Looks like it's a problem with my installation, and/or a bug at 10.2. Thanks for verifying. – Stephen Lead Jun 25 '15 at 03:35