I've taken the code snippet below from a larger block of code in order test it and made a script tool with it in ArcMap:

import arcpy
#Set join parameter variables
inFeatures = arcpy.GetParameterAsText(0)
inField = arcpy.GetParameterAsText(1)
joinTable = arcpy.GetParameterAsText(2)
joinField = arcpy.GetParameterAsText(3)
arcpy.MakeFeatureLayer_management(inFeatures,"inFeatures_lyr") #make feature layer from feature class
#Join road feature class to buffer distance table
arcpy.AddJoin_management("inFeatures_lyr", inField, joinTable, joinField, "KEEP_ALL")

In setting up the script tool, I've defined the variable inFeatures as a feature class, inField as a field, joinTable as a table, and joinField as a field. When I run the tool no errors are generated but no join is created.

Is there a problem with this code snippet?

Is the arcpy.MakeFeatureLayer_management unnecessary or causing problems?

closed as unclear what you're asking by PolyGeo Jun 17 '17 at 7:48

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you tested the join tool outside your script using the tables to prove a valid join is indeed created? Also looking at your code I see no immediate problem which suggests the join is created, without seeing the rest of the code it's hard to suggest anything as we don't know if you run a remove join later in the code? – Hornbydd Jun 15 '17 at 14:53
  • There is a remove join in the larger code but it's commented out because I haven't been able to do a successful join. I ran the AddJoin_management as a stand-alone in the python window in ArcMap and it worked there. – SD Robinson Jun 15 '17 at 14:56
  • 2
    @SDRobinson As per your other questions, please include the actual values instead of arcpy.GetParameterAsText. Have you tested it with hard-coded values? What was the result? – Midavalo Jun 15 '17 at 15:01
  • I seem to get the same outcome using hard-coded values in PythonWin; it appears to run but there's no values joined to the feature class. I have to use MakeFeatureLayer_management on the input feature class, else I get an error. – SD Robinson Jun 15 '17 at 17:22
  • I can run the script with hard-coded values in the ArcMap Python window and it runs correctly. – SD Robinson Jun 15 '17 at 17:24