I've been using an ArcPy script for a little while now that applies the symbology ('unique values, many fields') from a template layer to a newly uploaded layer to avoid having to set the symbol, font, unicode, and size, every single time I upload a new version of the file.
This code has worked perfectly fine in the past. It creates 9 different values from 2 value fields. However, today I ran into a problem when the data I uploaded needed only 8 of the 9 values. The symbology didn't display at all and I had to manually change the symbology for each of the 8 values.
I was wondering if there was a way to modify the code so that it would check to see if a value needed to be created or not, and didn't create it if it wasn't needed, avoiding this error.
For example: If only 6 values were needed, the symbology for 6 values would be applied rather than all 9 (thus breaking the symbology for the layer).
I'm not sure if you need my code but I'll provide it anyway. It's pretty simple:
addLayer = arcpy.mapping.Layer("symbology template layer") arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") symbLayer = r"smybology template layer" arcpy.ApplySymbologyFromLayer_management("layer that needs symbology", symbLayer) for lyr in arcpy.mapping.ListLayers(mxd, "", df): if lyr.name.lower() == "symbology template layer": arcpy.mapping.RemoveLayer(df, lyr)