I have been using it w/ no problem since I up graded ArcGIS Desktop from 10.3 to 10.4.
As Dan says, without proper formatting, it is very hard to tell.
But what is your select clause supposed to be doing?
The other thing is, have you considered just running this as a plain python script before you turn it into a script tool, with all the extra that entails.
Try using AddFieldDelimiters to handle the quotes:
>>> fc = 'points' ... sort_field = 'FID' ... w_clause = arcpy.AddFieldDelimiters(fc, sort_field) + ' < ' + str(5) # or str(i+1) ... arcpy.SelectLayerByAttribute_management(fc,"NEW_SELECTION",w_clause)
The problem is the variable SORT FIELD = "OBJECTID" and the data had no OBJECTID field. It had OID field.
It's quite simple. I am a rookie in Python.
Next time, I will post the sample code as Dan Patterson and Neil Ayres suggested.
Shapefiles will have a FID and generally an OID field, the first is required, the 2nd is sometimes generated.
Geodatabase featureclasses will have the OBJECTID field.
Glad you figured it out. If you want to save yourself this headache in the future, you can get the unique ID field dynamically like this:
>>> fc = 'myFeatureLayer' ... print arcpy.Describe(fc).OIDFieldName ... FID