I have written a simple code to list all fields associated with each feature layer in an mxd. I want to inventory the visible fields and field aliases associated with map services.
The field alias that is being returned is the database alias, not the one set in the mxd. Is there any way to get the layer field alias?
for field in field_list:
f_name = field.name
arcpy.AddMessage("> Field Name: "+f_name)
f_index = field_info.findFieldByName(f_name)
f_vis = field_info.getVisible(f_index)
arcpy.AddMessage("> Field Visibility: "+f_vis)
f_alias = field.aliasName
arcpy.AddMessage("> Field Alias: "+f_alias)
f_type = field.type
arcpy.AddMessage("> Field Type: "+f_type)
I believe the mxd field aliases are stored in the mxd document and are not available via arcpy.
To illustrate, I created a simple point feature with a field named "FieldName" and gave it an alias of "FieldAlias". I added it to an mxd file.
In the mxd file, I changed the field's alias to "MxdAlias".
When I examine the feature properties in the data base, the alias still shows as "FieldAlias". However, when I examine the contents of the mxd file, I can see the renamed alias listed along with the original field name.
alias name is read and write
with the small caveat …
Updating a field property only updates the field object, no changes are made to the actual field in the table or feature class.
What I need to read is the layer field alias, rather than the table field alias. I have not been able to do this with Python. Is this possible?
What I'd like to do is send a list of all layers, visible fields and their alias' out, and have people enter the alias they want to see in the map service, so I need info on the layer alias.