HI Dan
Thanks for the advice about the code rendering. I have now fixed this is the post.
I am bit confused by the 'Current' not being known as I am able to switch the Heights layer off in the map simply by adding the following lines to the script:
lyrs = map.listLayers(World5m_Heights)
lyrs[0].visible = False
The full script then becomes:
import arcpy
aprx = arcpy.mp.ArcGISProject('Current')
map = aprx.activeMap
Heights = "Heights"
toTable = r"C:\#workspace\Names"
lyrs = map.listLayers(Heights)
lyrs[0].visible = False
arcpy.AddJoin_management(Heights, 'LINK_ID', toTable, 'AI_LINK_ID', 'KEEP_ALL')
This would indicate that the layer is being referenced and manipulated OK using the script. However, the join does not work. If I change the parameters in the join to...
arcpy.AddJoin_management(lyrs[0], 'LINK_ID', toTable, 'AI_LINK_ID', 'KEEP_ALL')
...it still doesn't work.