Hey everyone,
I have a python script that I wrote which creates a feature class and overwrites a feature class in my geodatabase then overwrites a feature on my enterprise portal. (11.1) Arc Pro Version 3.2.
The issue I have is that this piece of code executes perfectly in the python window, and in a notebook. It will run in the toolbox with no errors but not update the single symbol symbology. I found a bug from 2021 but I am unsure if it was solved.
#Apply Symbology to new layer
symbol = MP.listLayers("Symbology")[0]
Publish = MP.listLayers("Active_DN_Inspections")[0] #creates variable for layer
arcpy.management.ApplySymbologyFromLayer(
in_layer = Publish,
in_symbology_layer = symbol,
symbology_fields = None,
update_symbology = "DEFAULT"
)
Solved! Go to Solution.
The symbology created in a script tool, the tool must include the layer as a derived output parameter.
The symbology created in a script tool, the tool must include the layer as a derived output parameter.
After much trouble and research I was able to get it to work by doing this:
results = []
res = arcpy.management.ApplySymbologyFromLayer(
in_layer = Publish,
in_symbology_layer = symbol,
symbology_fields = None,
update_symbology = "DEFAULT"
)
results.append(res)
arcpy.SetParameter(2, results)
where parameter 2 is set up like this:
Label: OutputLayer
Data Type: Layer
Type: Derived
Direction: Output