It is possible to change fields alias in layer within mxd by arcpy?(Table Options > Appearance)
Updating a field property only updates the field object, no changes are made to the actual field in the table or feature class.
Updating a field property only updates the field object, no changes are made to the actual field in the table or feature class.
When a geodatabase feature class is added to ArcMap, its field aliases are used initially for the layer field aliases. However, after this there is no link between the two. Properties set in ArcMap will override the properties of the data source, but they will not be carried back to the data source. This means that if you change a layer field alias, it will not change the feature class field alias, and if you change a geodatabase field alias, it will not update the layer field alias for any existing layers based on the feature class.
Have you found any other method to update the field alias in an mxd layer ?
Our SDE contains the updated alias but not able to update in mxd.
Well, I've spent too many hours trying to solve this issue.
How you solved your issue.
For what it is worth now, I kind of found a way to indirectly do this. Although it is not directly altering the field alias in the MXD, this way does seem to work. I create a data inventory of my feature classes in the gdb in a csv file. I then update all my aliases and stuff in the csv. I then run my next script that uses the AlterField tool to make the changed in my csv file to my feature classes.
All pretty standard and non-mxd(ish) up until now.
From here, I made use of T. Wayne Whitley reply from this thread which actually goes through to update the field visibility setting for the relevant layers using fieldInfo. Once the new layer is added/updated, the feature classes field alias seems to be updated also. I then use mxd.saveACopy to make a new output mxd.
Hope this helps.
Julian
Have you tried Alter Field—Data Management toolbox | ArcGIS for Desktop ?
Alter Field tool is to rename fields or field aliases for any feature class. I've already updated alias name in feature class. Since MXD layers have separate field mappings, the alias from the SDE fields are not reflecting in MXD layer. Hence thought of reading the layers from mxd and update the field alias.
As Jeff Barrette said, I've tried the UpdateLayer method. This has to be executed with the flag symbology_only=False for updating the fields. When I executed this, I lost the symbology.
This can be done like this (all arcpy, except step 2):
1) Use arcpy.ListFields() to get field names and field aliases from a feature class, and output to a csv file
2) In the csv file, update the alias column
3) Using arcpy, re-add the feature class to the map document (mxd) - it will have the wrong symbology
4) Use arcpy.ApplySymbologyFromLayer_management() to update the symbology
5) Use arcpy to delete the original layer from the MXD
Just be aware that ApplySymbologyFromLayer_management may not bring across all layer properties, e.g. Definition Queries.