I am trying to remove joins from a layer using arcpy.
When I type in the python window the line:
it works fine and the layer in the TOC does not have joins any more.
Then I tried in python that runs from a tool:
map1 = arcpy.mp.ArcGISProject("current").listMaps()
lyr = map1.listLayers()
It does not return any error but does not work (joins still exists).
Then I understood that I need to take the result from the tool:
updateLayer = arcpy.management.RemoveJoin(lyr)
It is working but then I have to try to insert the layer to the original position (it is not 0 as my example it is inside some groups) and remove the original.
Is there any simple way to make it works in one command just like when I type it in the python window?