I'm encountering an AttributeError when calling updateConnectionPropertieson a layer.
This error is also inconsistent:
There is also no descriptive error message (it just says AttributeError).
I've verified that:
Any help would be appreciated.
Is it maybe a group layer or something?
I've been running into a similar issue. At first I thought it was the upgrade from 3.2.0 to 3.2.2, because my code worked before. However, the solution for me was to update the connection properties on the layer file. I'm working within a toolbox within the project, and I don't know if this will work if you are running a script outside the project.
proj = arcpy.mp.ArcGISProject("CURRENT")
current_map = proj.createMap("Name for the map")
current_map.openView()
lyrx = arcpy.mp.LayerFile(path to layer file)
_layer = current_map.addLayer(lyrx)[0]
cp = {'dataset': name of the feature class, 'workspace_factory': 'File Geodatabase', 'connection_info': {'database': path to the file geodatabase}}
lyrx.updateConnectionProperties(None, cp)
_layer = current_map.addLayer(lyrx)[0]
_layer.name = nm