Hi All,
Im trying to automate a couple of processing at work but Ive hit a brick wall in trying to change the length of a field in a FC.
I want to get the script to iterate over all of the FC's in a dataset and all of the fields of that FC to find the string/text fields but I cant seem to ge the alterfield_management correct and its driving me crazy.
I was doing this on empty FCs andI have seen solutions that create a new FC with the same fields but extended length but this isn't a option because I have many domains attached to the many fcs.
import arcpy #Set workspace arcpy.env.workspace = r'C:\Users\daniel\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\gdb' #Loop through feature classes looking for a field that is a string' fcList = arcpy.ListFeatureClasses() #get a list of feature classes for fc in fcList: #loop through feature classes fieldList = arcpy.ListFields(fc) #get a list of fields for each feature class for field in fieldList: #loop through each field if field.type == 'Text': arcpy.AlterField_management(fc, field.name, '', '','','2000')
I only want to edit the field length and not any other feature. Any help/feedback if youve had success would be welcome, thanks!
I suspect you aren't working with empty (aka new) tables from the help
The new length of the field. This sets the maximum number of allowable characters for
each record of the field. This option is only applicable on fields of type TEXT or BLOB.
Only applicable if table is empty.
Hi dan,
Thanks for having a look.
I can confirm I was performing this on empty fc's. I want to avoid creating new fc's as there are alot of domains applied to many fc's in the dataset and it would be a hassle apllying them again.
Hi Dan,
Thanks for taking a look! I can confirm these fc's are empty as they are used as templates. I will try testing with another dataset to see if this could be the problem though.
I wanted to avoid creating new FC's because the current ones have many domains attached (possible issue?).
Hi Dan,
Thanks for taking a look! I can confirm these fc's are empty as they are used as templates. I will try testing with another dataset to see if this could be the problem though.
I wanted to avoid creating new FC's because the current ones have many domains attached (possible issue?).
Hi Dan,
Thanks for taking a look.
I was doing this on empty FCs so this should have been the problem. But I will give the script a run on a completely new table.
I have seen solutions that create a new FC with the same fields but extended length but this isn't a option because I have many domains attached to the many fcs.
Daniel