Select to view content in your preferred language

How do I alter field length of a string with Alter Field tool in Model Builder?

2485
6
10-02-2017 11:01 AM
MelissaTraverso
Regular Contributor

Hi I am realizing that for some reason my string fields are over a million characters long and when it gets published to my web map it makes the map run extremely slow. I have a tool set up that allows you to input a new csv file and go from CSV-> ArcSDE feature class so that way the web map can get automatically updated. In doing so I would like to add the alter field tool in my model builder so that I can trim the string fields down to an appropriate length before it gets added to ArcSDE.

The alter field tool won't let me change the field length unless the table is empty. I have a part in my model builder where the attribute table is deleted and then appended with the updated information. I want to add alter field after delete and before append. When I do this it won't let me choose a field length because its not recognizing in this step that the feature class is empty. Does anyone know how to get this to work? See attached image of my model builder.

Thanks,

Melissa

0 Kudos
6 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Melissa,

Try setting a precondition on the Append tool so that it will not execute until after the Alter Field tool is executed, and/or use the Output from the Alter Field tool for the Target Dataset in the Append tool.

0 Kudos
MelissaTraverso
Regular Contributor

Hi Jake,

Thanks for the reply! My idea originally was to use the output from the alter field tool to be the target dataset in my append tool but the alter field tool won't allow me to change the field length. Its greyed out (see below). When I read about the new field length option it says its only applicable if table is empty and this is why I figured it would be best to place after delete and before append since the output from delete tool will be empty. I just can't seem to figure out why the alter field tool isn't recognizing the output layer from delete as empty to allow me to change the field length for my string fields.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

I don't think there will be a way to do this in Model Builder.  You may have to create a new field, delete the old field, and then rename the new field.

curtvprice
MVP Esteemed Contributor
I just can't seem to figure out why the alter field tool isn't recognizing the output layer from delete as empty to allow me to change the field length for my string fields.

This is because Model Builder (with few exceptions) does its validation up front before the model runs. When have I run into this issue, I have gotten around it by using Calculate Value to run the tool inside a Python code block where Model Builder's validation checks are not used.

MichaelVolz
Esteemed Contributor

Were you able to resolve this problem?  I am trying something similar and even though the field length is altered to be longer I am still getting errors when try to append records to the feature class where the field length has been increased as if the python code does not recognize the change.

0 Kudos
MicahBabinski
Frequent Contributor

Hey Melissa,

Is the table actually empty after you use delete rows? You might try using Truncate Table—Help | ArcGIS for Desktop instead. Also, I would connect the output of your alter field tool to the append to get the correct order of operations.

Micah

0 Kudos