Is it possible in Python to apply the legend from a template layer file to a SDE based feature layer with a GDB table joined to it where the value field being used for the unique values symbology is in the joined table? The script I have worked in ArcGIS 10.2 but since we moved to 10.4.1 the 'arcpy.mapping.UpdateLayers' tool is no longer functioning as it did before.
The problem I see is with the field name after the join has taken place. For example, the template layer and respective GDB table both have the field "GDE_Code", but once the table is joined to the feature class this field becomes something like "Building.GDE_Code". So when I run the 'arcpy.mapping.UpdateLayers' tool in the script it will apply the legend from the template but no features will be displayed.
If I were to export the Building join to its own template layer and then use that one in the script on the joined Building feature layer everything works perfectly; however, is it possible to make the template generic so that it will work on other feature classes?
I've also tried using the 'arcpy.ApplySymbologyFromLayer_management' tool but it doesn't do anything.
This has been attempted as both a stand-alone geoprocessing tool and within the Python window of a Current ArcMap session.
One resolution I have seen is to export the joined feature layer to its own feature class so that the field name is just "GDE_Code", but ideally the goal is to perform this operation on a feature layer that is linking a SDE feature class to a file geodatabase table.
Here is the offending portion of script:
layers = arcpy.mapping.ListLayers(mxd, "*", df) for layer in layers: layer2update = arcpy.mapping.ListLayers(mxd,layer,df) layer2update.visible = False layerName = layer2update.name if layerName in FTRTables: GDBtable = os.path.join(FTRepGDB,layerName) arcpy.AddJoin_management(layer2update,"facilityIDFK",GDBtable,"facilityIDFK","KEEP_ALL") desc = arcpy.Describe(layer2update) geometryType = desc.shapeType if geometryType == 'Polygon': arcpy.mapping.UpdateLayer(df,layer2update,Polygon,True) elif geometryType == 'Point': arcpy.mapping.UpdateLayer(df,layer2update,Point,True) elif geometryType == 'Polyline': arcpy.mapping.UpdateLayer(df,layer2update,Line,True) else: pass else: pass