Correct. The script does not create the Join, but ModelBuilder and the out of the box geoprocessing tool do.
The script is run within Pro.
- The in_layer_or_view is a hosted feature layer.
- I have tried variables for the path + layer as well as the simple layer name as found in the map. Both of which demonstrate a successful run (the green checkmark). Below is the script which uses the simple layername:
- To confirm it does or does not work, I check two sources.
- One is to open the in layer attribute table which does not contain the join fields
- The other is to look at Data Tab-->Joins pulldown menu where "Remove Join" and "Remove All Joins" are grayed out.
- The only difference I see in the Script and Geoprocessor is the Parameters from History where the Script has no parameters but the Geoprocessor notes an updated layer (see attachment)
import arcpy
#Reference map document from within ArcGIS Pro
aprx = arcpy.mp.ArcGISProject('CURRENT')
map = aprx.activeMap
# Process: Add Join (Data Management)
path = "\\\\localpath\Test.gdb\\"
hostedpath = "https://services7.arcgis.com/zHNS16tz3znqN3gM/arcgis/rest/services/TEST_gdb/FeatureServer/0"
feature1 = "SWNODE"
feature2 = "JUNK"
infeature1 = hostedpath
infeature2 = path + feature2
arcpy.AddJoin_management(feature1, "INPUTID", "feature2", "INPUTID", "KEEP_ALL")