I need to create a python script that can update attribute alias of "Query Layers" added in MXD.
arcpy.AlterField_management throws ERROR 001601: Failed to alter field alias. Failed to execute (AlterField).
Any Help or suggestions are appreciable!
Is Query Layers a layer in a Geodatabase table?
http://pro.arcgis.com/en/pro-app/tool-reference/data-management/alter-field-properties.htm
The error means that the alias is invalid and says to try another one
which may mean that the alias is a reserved word or it exists or a number of other reasons...
Try 'ABC' and see if that works as a test
I wonder if Alter Field—Help | ArcGIS Desktop supports a Query Layer. Can you post you have tried?
Query Layer is a geodatabase view. I have already tried alias name like "XYZ"
As in the help link...
This tool provides the ability to rename fields or rename field aliases for any geodatabase table or feature class.
I suspect you are going to have to go directly to Modify a query layer
By "geodatabase view," I interpret that as a database view that has been registered with a geodatabase. Are you creating or working with a query layer defined against the geodatabase view above? Query layers work best for enterprise databases that are not geodatabases, so if you have already registered a view with the geodatabase, why load it into ArcMap using a query layer instead of a regular layer?
My experience has been there isn't much support for Query Layers in ArcPy. A while back I needed to build a GP tool that would update query layer definitions based on database name/schema changes between Dev, Test and Prod environments, but there doesn't seem to be any support for that kind of thing in ArcPy. (I'm not sure there's even a reliable way to distinguish between query layers and regular EGDB layers in a map document.) Ultimately ended up building the GP tool using ArcObjects, where there are interfaces like IQueryDescription.