I'm trying to join two feature services with a common field through model builder. It works properly when I run the standard Add Join tool through the geoprocessing pane. I then go to the geoprocessing history, use the successful result Add to Model and save the new model. When I run the new model from my toolbox, it will not work properly. It says it completes successfully, but there is no join afterwards. What is going wrong? Attached below is the python script from model builder (I am not familiar with python). I'm using Pro 2.8.1
# -*- coding: utf-8 -*- """ Generated by ArcGIS ModelBuilder on : 2021-07-28 08:57:11 """ import arcpy def Model10(): # Model - join reforest & harvest # To allow overwriting outputs change overwriteOutput option to True. arcpy.env.overwriteOutput = False LGL_Silvi_Reforestation_2_ = "ACTIVITY LAYERS\\LGL_Silvi_Reforestation" LGL_HarvestActivities = "ACTIVITY LAYERS\\LGL_HarvestActivities" # Process: Add Join (Add Join) (management) LGL_Silvi_Reforestation_3_ = arcpy.management.AddJoin(in_layer_or_view=LGL_Silvi_Reforestation_2_, in_field="StandKey", join_table=LGL_HarvestActivities, join_field="StandKey", join_type="KEEP_ALL") if __name__ == '__main__': # Global Environment settings with arcpy.EnvManager(outputCoordinateSystem="PROJCS["NAD_1983_UTM_Zone_16N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-87.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]", preserveGlobalIds=True, scratchWorkspace=r"C:\Users\Lgilner\Documents\ArcGIS\Projects\ArcPro Project Update 040121\Default.gdb", workspace=r"C:\Users\Lgilner\Documents\ArcGIS\Projects\ArcPro Project Update 040121\Default.gdb"): Model10()
Well....maybe it is working. I continued the model with some Calculate Fields to pull attributes from the joined feature, and the attributes pulled through correctly. Why doesn't it show that there is a join on the feature when I run my tool from the toolbox, but it does when I run it directly from model builder?
I would think your a join will only appear if they are created in relation to maps in the project - If you run a tool and then select the data sources from the 'current' map. We could build and run a model in Pro that creates a join as a step in a model that uses data sets directly (e.g., c:\temp\myshapefile.shp) that are not in the current project and these joins would only exist in the context of the model.