List mxd-specific layer field alias names.

996
3
07-11-2018 07:45 AM
by Anonymous User
Not applicable

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)

Thank you,

Randy McGregor

0 Kudos
3 Replies
RandyBurton
MVP Alum

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.

Alias 1

In the mxd file, I changed the field's alias to "MxdAlias".

Alias 2

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 3

DanPatterson_Retired
MVP Emeritus

alias name is read and write

Field—ArcPy classes | ArcGIS Desktop 

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.
by Anonymous User
Not applicable

Thank you,

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.

Thanks

Randy

Randy.

0 Kudos