FieldInfo GetVisible method returns "VISIBLE" even when field is hidden

03-23-2017 01:40 PM
by Anonymous User
Not applicable

I have a script which lists properties for each field in the layers in an mxd, including its "visible" status.

"Shape_Length" and "Shape_Area" fields are all given a visibility status of "VISIBLE"

They are all turned off. Every other turned off field is given a status of "HIDDEN"

Any idea why this is happening? Is this a bug?

Thank you,

Randy McGregor

7 Replies
by Anonymous User
Not applicable

Thanks. My first posting  on GeoNet (I used ESRI forums YEARS ago.) I appreciate the advice.

0 Kudos
MVP Regular Contributor

What script/code are you using?  Something like:

mxd = arcpy.mapping.MapDocument("CURRENT")

for lyr in arcpy.mapping.ListLayers(mxd):
    print "\n\nLayer Name: " +

    # Create a describe object
    desc = arcpy.Describe(lyr)

    # If a feature layer, continue
    if desc.dataType == "FeatureLayer":

        # Create a fieldinfo object
        field_info = desc.fieldInfo

        # Use the count property to iterate through all the fields
        for index in range(0, field_info.count):
            # Print fieldinfo properties
            print("Field Name: {0}".format(field_info.getFieldName(index)))
            print("\tNew Name:   {0}".format(field_info.getNewName(index)))
            print("\tSplit Rule: {0}".format(field_info.getSplitRule(index)))
            print("\tVisible:    {0}".format(field_info.getVisible(index)))

Based on  FieldInfo page.

It does appear that some fields like OBJECTID, SHAPE will show as VISIBLE even if turned off. Perhaps it relates to geometry properties and the @ token??

by Anonymous User
Not applicable

Almost exactly like that, yes.

It does appear as though the geometry fields are simply ignoring the getVisible method.

"SHAPE" and "OBJECTID" fields are turned on so they may have the same problem if they were turned off.

I can just tweak the code to say "HIDDEN" for all Shape_Length and Shape_Area fields and just hope I remember to hide them, so I don't make  a liar out of my fields information report

Thank you,

0 Kudos
New Contributor III

Not that it helps but FYI: This has been confirmed by ESRI support as a bug:

Bug NIM101408 : The fieldinfo.getvisible method always returns Visible for OBJECTID and SHAPE fields.

This issue has a current status of "in product plan", meaning that it is down for an eventual fix. Bug report can be found here: NIM101408: The fieldinfo.getvisible method always returns Visib.. 

0 Kudos
MVP Esteemed Contributor

As much as "In Product Plan" is better than a couple of the alternative status states, seeing the bug has been around since 10.2.2 and not fixed yet doesn't give me hope.  It might get fixed, but it will be more a byproduct of some other issue being addressed than being fixed directly.  Now if someone wants to get an EEAP and pay Esri to fix it, then we might get somewhere.

0 Kudos
New Contributor III

Would be nice if they fixed this bug...  Still present in Pro 3.0 and got demoted to "Will not be addressed."

You cannot publish a layer to AGOL if the "Shape" field is hidden, and there doesn't appear to be any way to check if that's the case before running the tool.  It's not the end of the world though, you just have to handle this error:

arcgisscripting.ExecuteError: ERROR 001272: Analyzer errors were encountered ([{"code":"00123","message":"Shape field is not visible","object":"layer_name"},{"code":"00102","message":"Selected layer does not contain a required layer type for web feature layer","object":"map_name"}]).


0 Kudos